You don't want the "o" suffix on your regex. In
if ($a =~ /$b/o), the "o" is making a promise that you won't change the value of $b, so perl doesn't recompile the regex for each $b you create. You probably
do want the "i" suffix to make the matching case-insensitive -- otherwise 'Hello' will not match 'hello'!
Consider this a starting point:
'Hello(world)' =~ m/hello\(\w+\)/i # is true
Replace the right side with the variable containing the current regex you want to match and you will be on your way.
BTW, it's generally a good idea to avoid using the variable names $a and $b because they have a special significance to perl (see perldoc -f sort).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.