"AND" and "OR" in regular expressions
Posted by enquirer (enquirer), 11 September 2003I 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 2003If you want to look for a string that contains both abc and def (for example), write
(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:
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.
edit your own (not yet published) comments
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho