B
Big Tony
Hi
I suspect this is an easy one and sits somewhere in a FAQ, but can
anyone help anyway?
Suppose I have two strings:
$str1 = "abcd%efg";
$str2 = "1234\%567";
I would a regular expression that will return "abcd" from $str1 and
"1234\%567" from $str2, i.e. if a "%" is encountered without being
preceded by a "\" then ignore it and the remainder of the string, but
if "\%" is encountered do nothing special and return it with the rest
of the string.
I guess I could use split to break the strings around the "%" and then
test for a trailing "\", but wondered if anyone could come up with a
one-liner.
cheers
BT
I suspect this is an easy one and sits somewhere in a FAQ, but can
anyone help anyway?
Suppose I have two strings:
$str1 = "abcd%efg";
$str2 = "1234\%567";
I would a regular expression that will return "abcd" from $str1 and
"1234\%567" from $str2, i.e. if a "%" is encountered without being
preceded by a "\" then ignore it and the remainder of the string, but
if "\%" is encountered do nothing special and return it with the rest
of the string.
I guess I could use split to break the strings around the "%" and then
test for a trailing "\", but wondered if anyone could come up with a
one-liner.
cheers
BT