laziness, impatience, and hubris | |
PerlMonks |
Re^3: Making a regex case insensitiveby johngg (Canon) |
on Mar 06, 2007 at 21:17 UTC ( [id://603515]=note: print w/replies, xml ) | Need Help?? |
While the case of '--' and ';' seems to be a matter of debate and jocose comment, you might like to know that you can switch case sensitivity on and off in different parts of a regular expression. You would use constructs like (?i), (?-i), (?i:text) and (?-i:text). The first two switch case insensitivity on and off respectively. The second two just apply their effect, insensitive or sensitive respectively, to the text inside the parentheses. Here is a contrived example that uses a precompiled (qr{ ...}) regular expression that also uses extended syntax, the x, to allow comments and white space inside the expression.
Here's the output.
I hope this is of interest. Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|