View Full Version : Requesting a RegExp...

10-05-2003, 05:13 PM
I posted something pretty much the same in the "server side" forum, but realised that the JS folks might have more experience with this:

I'm simply looking to match "wordhere/" (ignore all my double quotes) where "wordhere" does not equal "admin" or "register". So this would be something like:


The trailing slash may or may not be there.

EDIT: Oh, and the "wordhere" needs to be captured. That's the trouble right there. Capturing the bugger is proving difficult.

Anyway, this doesn't work. Any ideas?

Thanks a whole heap in advance.

Jeff Mott
10-05-2003, 07:26 PM

10-05-2003, 08:20 PM
Negative lookaheads are not the best supported feature of JS regexes. Why not do a two-stage confirmation instead?
r=(/^(admin|register)/i).test([string path])?
(/^([^\/])/i).match([string path]);

10-05-2003, 10:41 PM
Yeah, I went with liorean's approach.

I got really close with a few of my own. Annoying that something this easy took me so long :o