| |||||||||||
| |||||||||||
"AND" and "OR" in regular expressions Posted by enquirer (enquirer), 11 September 2003 I am very new to regular expressions and I have managed to build a simple search using Case sensitivity, folder selection a logical OR statement. But, how do you perform a logicalAND.I am using ASP and I am very stuck.Posted by admin (Graham Ellis), 11 September 2003 If you want to look for a string that contains both abc and def (for example), writeabc.*def (that's dot star between the abc and def), and that will match if the input string contains abc followed later by def. If you don't know whether the abc or def will come first (if, for example, you're writing a search algorithm to find pieces of data that contain every one of a number of elements), don't try and write a single complicated regular expression - write a loop instead. I don't know what language you're using within ASP - personally I like Perl; here's a Perl example that checks if a text string contains abc and def: Code:
Works for any number of search strings in any order, and returns you a variable called $matched with a true value (1) if it matches all, false (0) otherwise. This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |