Do you know where your variables are? | |
PerlMonks |
Re: Matching '=' and other non alphanumeric characters using regular expressionsby MarkM (Curate) |
on Dec 13, 2002 at 06:19 UTC ( [id://219511]=note: print w/replies, xml ) | Need Help?? |
'.' will (normally) match all characters except for the newline character. The regular expression that you are looking for is probably: if ($string =~ /^DEFINITION[ \t]+([^\r\n]*)/mg) {In english, this would be: A line in $string that begins with the literal string 'DEFINITION' followed by any amount of simple white space (' ' and '\t') followed by a string of characters that do not include '\r' or '\n'. This will grab all characters to the end of the line, but not the end-of-line character sequence itself. I choose to use [^\r\n]* instead of .* as I regularly have to ensure that my code will function equally well under both UNIX and WIN32. Using [^\r\n]* instead of .* allows me to ensure that '\r' is not picked up at the end of $1.
In Section
Seekers of Perl Wisdom
|
|