Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] RegExp for parsing search strings
- From: wdlists at triche-osborne.com (Triche Osborne)
- Subject: [Javascript] RegExp for parsing search strings
- Date: Fri Apr 28 15:50:51 2006
Paul Novitski wrote: > Given a typical search string potentially consisting of any number of > single terms and quoted phrases, such as these examples: > > item1 > item1 item2 > "phrase one" > "phrase one" "phrase two" > "phrase one" item2 "phrase three" item4 > > design a regular expression that splits it into its components, e.g.: > > source: > item1 "phrase two" item3 item4 "phrase five 5" "phrase six" item7 > result: > item1 > phrase two > item3 > item4 > phrase five 5 > phrase six > item7 > 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. Triche
- Follow-Ups:
- [Javascript] RegExp for parsing search strings
- From: Scott Reynen
- [Javascript] RegExp for parsing search strings
- From: Paul Novitski
- [Javascript] RegExp for parsing search strings
- References:
- [Javascript] RegExp for parsing search strings
- From: Paul Novitski
- [Javascript] RegExp for parsing search strings
- Prev by Date: [Javascript] RegExp for parsing search strings
- Next by Date: [Javascript] RegExp for parsing search strings
- Previous by thread: [Javascript] RegExp for parsing search strings
- Next by thread: [Javascript] RegExp for parsing search strings
- Index(es):