|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
Re: Can I ask a quick stupid question?
|
> ... 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**
|
|