pysome has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl $s = "a000000000b"; if ($s =~ /^a.*(?!ab).*b$/) { print "yes"; } else { print "no"; }
My ideal result is to match string that : 1)start with "a" 2)end with "b" 3)don't include "ab" between them. That is to say, "a000000000b" : matched "a0a0000b00b" : matched but "a0000ab000b" : unmatchedI use negative look-ahead assertion (?!ab) ,but it can't work.Can somebody help me?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A Regex simple Question
by FunkyMonk (Bishop) on Sep 06, 2007 at 15:52 UTC | |
|
Re: A Regex simple Question
by Sidhekin (Priest) on Sep 06, 2007 at 15:54 UTC | |
|
Re: A Regex simple Question
by johngg (Canon) on Sep 06, 2007 at 15:55 UTC | |
|
Re: A Regex simple Question
by ikegami (Patriarch) on Sep 06, 2007 at 15:54 UTC | |
|
Re: A Regex simple Question
by johnlawrence (Monk) on Sep 06, 2007 at 16:04 UTC | |
|
Re: A Regex simple Question
by moritz (Cardinal) on Sep 06, 2007 at 15:56 UTC | |
by ikegami (Patriarch) on Sep 06, 2007 at 16:11 UTC | |
by moritz (Cardinal) on Sep 06, 2007 at 16:36 UTC | |
|
Re: A Regex simple Question
by injunjoel (Priest) on Sep 06, 2007 at 16:29 UTC |