[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Yet another regex question
- Subject: [ale] Yet another regex question
- From: joe at madewell.com (Joe Steele)
- Date: Sat, 13 Aug 2005 19:28:54 -0400 (EDT)
- In-reply-to: <[email protected]>
Try this pattern: '^(.?|.*([^%] |[^ ]))XMI001'
The pattern you are using below is equivalent to '[^%].XMI001|\SXMI001',
requiring that your text match either:
'[^%].XMI001' (requiring at least two characters before the alarm), or
'\SXMI001' (requiring at least one non-whitespace character before the
alarm).
--Joe
On Sat, 13 Aug 2005, Christopher Fowler wrote:
> It only works when there are 2 spaces in front of the alarm
>
> [cfowler at shuttle ~]$ ./regex.pl '([^%].|\S)XMI001' 'XMI001'
> No
> [cfowler at shuttle ~]$ ./regex.pl '([^%].|\S)XMI001' ' XMI001'
> Yes
>
>
> Maybe I'm doing it wrong?[cfowler at shuttle ~]$ cat regex.pl
> #!/usr/bin/perl
> die "regex.pl <regex> <test string>\n" unless $ARGV[0] and $ARGV[1];
> my $regex = $ARGV[0];
> if($ARGV[1] =~ m/$regex/) {
> print "Yes\n";
> } else {
> print "No\n";
> }
>
>
> The only reason I'm using perl this way is to test the regex.
>