Chris Spurgeon on Tue, 22 Feb 2000 17:07:15 -0500 (EST) |
Thanks! Yeah, I know about '+' being a special character for regular expressions, but I kept trying to get around it...I was too brain-fried to remember to just use index. Thanks! On Tue, 22 Feb 2000 mjd-perl-pm@plover.com wrote: > > > ... what I'm trying to do here is search for a series of strings, where > > the strings happen to end with the characters "+++". But perl is picking > > up those final characters in $alteredsearcher and it's seeing them as a > > syntax error instead of just three characters. What am I missing here? > > `+' is special in a regular expression. It means to repeat the > preceding item one or more times. X+++ doesn't make sense, since > you're asking to repeat X one or more times, repeated one or more > times, repeated one or more times. > > Probably the simplest thing to do is to use the `index' function > instead of a regex. Instead of: > > > if ($teststring =~ /$alteredsearcher/) { > > use > > > if (index($teststring, $alteredsearcher) >= 0) { > > > The whole point of regexes is that they have these magical characters > like + and * and . that do special things; if you don't want those > special behaviors, and you just want to see if one string is in > another, `index' is the function to use. > > **Majordomo list services provided by PANIX <URL:http://www.panix.com>** > **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org** > _____________________________________________________________ Chris Spurgeon | "So much time,...so little to do." WHYY webmaster | -- Stan Laurel ces@www.whyy.org | http://whyy.org | **Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|