
RegEx Question: No stingy matching?
Hans,
Thanks for clarifying that. Is JScript 5.5 the same as I.E. 5.5?
I use I.E. 5.5 and Netscape 4.75 and one of them (don't remember which one)
was not implementing this construct. For now, I've switched to a more
traditional (in JavaScript anyway) use of indexOf() and substring() methods
to do the same work.
Thanks again Hans. Take care now.
-John
Quote:
> Up to MS JScript 5.0 the regexp only had greedy matches.
> JScript 5.5 also has non-greedy matches (as they are called there)
> For Netscape I don't know.
> Hans Kesting
> > Hi,
> > In perl, I can make matching stingy with a ? after the * so that
> > this....
> > t += lines[i].replace(/(.*?)\/\/.*$/g, "$1");
> > Will match everything up to the FIRST set of forward slashes and add it
> > to t
> > In perl, if there was no ? after the .* the $1 would contain everything
> > up to the LAST set of forward slashes, because matches are greedy in
> > perl unless you include the question mark.
> > Greedy matches seem to be the case in JavaScript regardless of if you
> > include the question mark or not. Is this true? Is there some other
> > mechanism for getting stingy matches?
> > Thanks if you can help....
> > -John Repici