More RegEx help, (looking back?)
yesterday DeadEyes thought be about ?= that is a look ahead assertion. But is there something for looking back too? I need to find a function definition. And it always has "def" infront of it. and a ( after it. So to find a function I can do:
\b[\w\d_]*(?=\()
but I need to add to that to match it ONLY if "def" is in front of it.
I.e:
def _ma5in_(
Anyone have any ideas.
ØØ
Re: More RegEx help, (looking back?)
yes there is
(?=) lookahead
(?<=) lookbehind
these are for positive matches there are also negative ones;some good info can be found here http://www.regular-expressions.info/
Re: More RegEx help, (looking back?)
wohhooo...will test it and see if I can make it work right away.
Re: More RegEx help, (looking back?)
Great page. Took me a while to understand that the look behind had to be in front of the expression I had to match..:D...but the syntax I have come up with now is like this..:)
(?<=def\s)[\w\d_]*
and it seems like it works. This is so fun..:D
Thanks a million.
ØØ
Re: More RegEx help, (looking back?)
Well it worked in my RegEx coatch testing tool. But JS is not eating it...:(...
Re: More RegEx help, (looking back?)
Hehe...I am pretty stupid though....JS doesn't support lookbehind at all..:D..thats why it isn't working...:D
So it is possible to use the ^ for a whole word in staed of just ONE letter? Because if I do this:
[^def] then it will just test for d or e or f. Not the word def. I have too rule out all matches that has the def word in front.
so it will trigger on this one:
if sef():
but not this one at all:
def _ma5in_():