Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] RegExp for parsing search strings


  • From: scott at randomchaos.com (Scott Reynen)
  • Subject: [Javascript] RegExp for parsing search strings
  • Date: Fri Apr 28 16:16:13 2006

On Apr 28, 2006, at 3:54 PM, Triche Osborne wrote:

> Okay, I'm going to ask a question which I'm sure has a reasonable  
> answer, but I can't help being curious: Why hasn't the source been  
> impregnated with a delimiter other than a space? This would make it  
> a simple matter of exploding (PHP) or splitting (JS) the string,  
> which avoids the drag that regex imposes on optimization in PHP.

When I did this, the answer to that question was that the source was  
a person, and people type searches with spaces between words.  What I  
did was just break it up by space, and then merge adjacent parts  
until each one had an even number of quote marks.  I think it would  
take a very complicated RegEx to do this because you'd have to figure  
out which quotes went together, and then you have to figure out what  
to do when there's an odd number of quotes.

Peace,
Scott