Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-05-2003, 04:13 PM   PM User | #1
AaronW
Senior Coder

 
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 1,223
Thanks: 0
Thanked 0 Times in 0 Posts
AaronW is an unknown quantity at this point
Requesting a RegExp...

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:

[^(admin|register)]+[\/]?

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.
__________________
offtone.com | offtonedesign.com

Last edited by AaronW; 10-05-2003 at 04:17 PM..
AaronW is offline   Reply With Quote
Old 10-05-2003, 06:26 PM   PM User | #2
Jeff Mott
Regular Coder

 
Join Date: Sep 2003
Posts: 290
Thanks: 0
Thanked 0 Times in 0 Posts
Jeff Mott is an unknown quantity at this point
Code:
/^(?!admin|register)(.*)\/$/i
Jeff Mott is offline   Reply With Quote
Old 10-05-2003, 07:20 PM   PM User | #3
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
Negative lookaheads are not the best supported feature of JS regexes. Why not do a two-stage confirmation instead?
Code:
var
    r=(/^(admin|register)/i).test([string path])?
        null:
        (/^([^\/])/i).match([string path]);
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 10-05-2003, 09:41 PM   PM User | #4
AaronW
Senior Coder

 
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 1,223
Thanks: 0
Thanked 0 Times in 0 Posts
AaronW is an unknown quantity at this point
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
__________________
offtone.com | offtonedesign.com
AaronW is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:10 PM.


Advertisement
Log in to turn off these ads.