[ale] Yet another regex question

Joe Steele joe at madewell.com
Sat Aug 13 19:28:54 EDT 2005


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.
> 
 




More information about the Ale mailing list