This Forum has been archived there is no more new posts or threads ... use this link to report any abusive content
==> Report abusive content in this page <==
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Javascript Regular Expression Odd Behavior?
10-01-2012, 01:25 AM
Post: #2
 
I believe the problem is here:
(^|\s)

Each match is created by finding the space between tags. (Since space matches [^A-Za-z0-9_]).

But that consumes the space!. When it loops back around to find the next match, the next character is going to be the #, which doesn't match (^|\s). So it keeps scanning until it finds a space, which skips over the next item.

I believe if you change (^|\s) to (\s)* it will work for your example. But I'm not positive it catches all scenarios, you'll need to test a bit.

Ads

Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[] - Ratchetr - 10-01-2012 01:25 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)