|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Find all strings containing "a" characters, that are not followed by "b" characters.by Kyshtynbai (Novice) |
| on Dec 12, 2012 at 17:13 UTC ( #1008535=perlquestion: print w/ replies, xml ) | Need Help?? |
|
Kyshtynbai has asked for the
wisdom of the Perl Monks concerning the following question:
Hi everyone! I'm learning perl using "Lama Book" and now I'm in the world of regexps. There's an exercise in d foy's book of exercises, which I still can't solve :(. Here it is: "Write a program to match a string that contains an “a”, but doesn’t have a “b” anywhere after the “a” ". I've written the following regexp, and is _seems_ to be proper (I've run some tests. I really does the job as far as I notice.), but in the answers section of this book there's a rather weired way to solve this exercise, which includes two "if" blocks. Here is the regexp I've written: /\ba\b|(\b.*a[^b]+\b)/Is it okay for this exercise, that's all I want to know :) . Thank you in advance.
Back to
Seekers of Perl Wisdom
|
|