Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Space or end of string in regex

by Marshall (Prior)
on Feb 03, 2012 at 20:47 UTC ( #951712=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Space or end of string in regex
in thread Space or end of string in regex

if( $line =~ m[^REM $sTest\s*$]i ) {
If you use the //, then you don't need the "m" in front, but otherwise its just style preference.

There is one other fine point about this, if $sTest could contain some characters that would normally mean something to the regex engine, like a "(" or whatever, you can specify to interpret the string $sTest literally - meaning ignore the meaning of those characters. This is done by surrounding $sTest with a \Q \E pair.

if( $line =~ /^REM \Q$sTest\E\s*$/i ) {


Comment on Re^3: Space or end of string in regex
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951712]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2015-07-03 06:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls