Regexen problems? Well the rule is that it will work really
really hard to find a match. So figure out why it is
finding the unwanted match and deny it.
Well on the second substitution it is clearly able to match
"0+" after a 1. Well does that fit the rule? Why yes, the
preceeding "1" is not "^", so it can match What to do?
Why deny it a digit there. That gives us:
s/(?<![\^\d])(?:\d+\+)//g;
# ^^^^^^ <- was just \^ before
which does what you asked. | [reply] [d/l] |
Hey tilly! thanks (for the fix and the plural i LIKE regexen as a word), i think i was getting google eyed trying to figure that out.. i was relatively sure it involved my not specifying the negassert correctly but i just continually woofed it! regexen are one way to kill your eyesight ;)
after a while they look like /{][P)(*^8(*(/ over and over :) p.s. still like the multfor "loop" you clued me in on (still studying it cause it's a cool hack!)
Mucho gracias! madams.
| [reply] |
In an effort to shamelessly plug my modules, I produce the output of the OGRE:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
(?<! look behind to see if there is not:
----------------------------------------------------------------------
\^ '^'
----------------------------------------------------------------------
) end of look-behind
----------------------------------------------------------------------
(?: group, but do not capture:
----------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
----------------------------------------------------------------------
\+ '+'
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
As tilly pointed out, the problem is that in the string "^123", "123" isn't a valid match, but "23" is.
japhy --
Perl and Regex Hacker | [reply] [d/l] |