Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: 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 reply to Re: Matching '=' and other non alphanumeric characters using regular expressions
by MarkM
|
|