[ale] Regex question
Mike Murphy
mike at tyderia.net
Thu Mar 11 23:36:39 EST 2004
ah, yeah, stuff like awk won't know what \d is. Try this:
echo XMI313 | awk '/XMI[0-9][0-9][0-9]/ {print $0}'
this is a little neater:
echo XMI333 | awk '/XMI[0-9]+/ {print $0}'
but could have unanticipated consequences. For instance, if you do that
with an input of something like 'XMI3334', its going to find that, but
that's also true of the first example. (because the substring matched.
That's probably ok for your purposes. If not, you might try anchoring
that with a ^ and a $ if necessary (assuming that would work for your
stream).
Mike
Christopher Fowler wrote:
> On Thu, Mar 11, 2004 at 11:13:04PM -0500, Mike Murphy wrote:
>
>>unless I'm missing something, something like this:
>>
>>=~ /(XMI\d\d\d)/ should work. The entire string matched will show up in
>>$1 afteward. This presumes that not other characters will show in the
>>string.
>
>
> I must be doing something wrong then, I'm using AWK to validate the regex.
> The perl Expect module will actually do the matching based on the regular
> expression so I do not think anything that is perl specific will work. That
> is why I'm testing with awk
>
> echo XMI | awk '/XMI\d\d\d/ {print $0}'
>
--
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Mike Murphy
781 Inman Mews Drive Atlanta GA 30307
Landline: 404-653-1070
Mobile: 404-545-6234
Email: mike at tyderia.net
Email Pager: pagemike at tyderia.net
AIM: mmichael453
JDAM: 33:45:14.0584N 84:21:43.038W
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
More information about the Ale
mailing list