in reply to Newbie regex question
$text = q"'$' and '***'"; $text =~ /\$(.*)\*\*\*/; print $1;
This yeilds: ' and ' The trick is to escape the $ and * with a \ (backslash).
The q in front of the quotes may look like a typo, but it saves me from having to use a lot of backslashes. Speaking of which, there is a way to not use so many backslashes in our pattern.
$text =~ /\$(.*)\*{3}/;
This has the same effect. The regexp is more compact as well. The {} allows me to say how many of the last character to match.
2001-03-11 Edited by Corion: Added CODE tags
|
|---|