Re: searching for a special string in an array
- From: "J?rgen Exner" <jurgenex@xxxxxxxxxxx>
- Date: Tue, 10 Jul 2007 13:47:46 GMT
Shai wrote:
I'm running on an array of strings with a foreach loop.
I want to stop the loop when I find the string: "item(s)" - but it
looks like I have problems with defining the if condition.
I tried:
if ($str=~"item(s)") {
It would be less confusing to you and others if you used the customary /.../
for REs.
Double quotes are a particularly poor choice because naturally people will
confuse the text with a string.
last;
}
But it seems to have problems. if I remove the "(s)" it works fine but
You need to escape the parantheses because they are using for grouping in
REs.
I need to find a unique string which contains exactly this: "item(s)".
Any idea ?!?!?
Even better: use the right tool. If you want to search for a substring
within another string then index() is your friend. No need to wield the big
RE cannon for that task.
jue
.
- References:
- searching for a special string in an array
- From: Shai
- searching for a special string in an array
- Prev by Date: Re: retrieving news messages
- Next by Date: TXL-like capability?
- Previous by thread: Re: searching for a special string in an array
- Next by thread: Re: searching for a special string in an array
- Index(es):
Relevant Pages
|