regular expressions for simple data search
Posted on 2005-04-25
i am trying to figure out how to write some proper regular expressions for one of my forms that can search selected data and fill in its listview. even with 'expresso' regular expression program. no luck so far...
input examples: (before i press 'search' button)
green* (green + anything)
*green (anything + green)
^apple (begins with 'apple' only)
apple$ (ends with 'apple' only)
a??le (any characters within a single '?')
apple AND green (self explanation) i might remove 'AND' and use white space only?
apple OR green (ditto)
seed (all data with 'seed')
these symbols will be replaced with simple RE by cs coding, for example:
* -> [a-z]+
? -> [a-z]
^ -> ^(?=string).*
$ -> .*string.$
none -> .*string.*
two words with AND -> (?=.*string)(?=.*string)
but if i put some tricky combinations, for example; ^g*n AND a??le$
i became stuck... any suggestions on flexible RE and CS coding?