davies has asked for the wisdom of the Perl Monks concerning the following question:
Again, I have some code that works but I'm sure it could be better written using a regex that I don't know how to write. My code is:
$sTest = uc($sTest); if (uc($sLine) eq "REM $sTest" || Left(uc($sLine), 5 + length($sTest)) + eq "REM $sTest ") {
Left is a sub I have written to help me until I get out of the habit of writing VBA instead of Perl. It's a very basic call to substr.
I have been trying to write something along the lines of:
if ($sLine =~ m/rem $sTest€/i) {
The problem I have is replacing the € with something that means "a space or the end of the string". I'm not sure whether Corion is hinting at how to do this in Re: Regex - Matching prefixes of a word or whether it means "one or the other, but not both in a single construct". Either way, that is the closest my searching has come to an answer. Is there a better one, please?
TIA & Regards,
John Davies
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Space or end of string in regex
by BrowserUk (Patriarch) on Feb 02, 2012 at 22:44 UTC | |
by davies (Prior) on Feb 02, 2012 at 23:00 UTC | |
by BrowserUk (Patriarch) on Feb 02, 2012 at 23:15 UTC | |
by Marshall (Canon) on Feb 03, 2012 at 20:47 UTC |