in reply to Regex Help
Rather than using the character class [\s\S], I think intent would be more obvious using . combined with the s modifier: if ($_ =~ /start(.+?)end/si)
I would probably also add word boundaries around your start and end, so you don't get false positives from words like 'send': if ($_ =~ /\bstart\b(.+?)\bend\b/si) Even better, if you know that start and end are on lines by themselves, use the m modifier to say as much: if ($_ =~ /^start\s*\n(.+?)^end\s*$/smi) Regular expressions play best when they are tightly constrained.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|