|
From: | Michael Terry |
Subject: | [Beaver-devel] Fixed strings inside extended regular expressions |
Date: | Wed, 23 Apr 2003 22:09:14 -0400 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030322 |
Hello. I am working again on Beaver after a long break. :)For searching, I would like to construct a regular expression from the user's input string. However, I sometimes want to treat the input string as a fixed string (that is, match '*' with only the character '*' and such), but want to surround this fixed string with regular expression syntax.
For example, let's say I have the string "o.*g". I want to prefix and postfix this with some regular expression, let's say to make it "^(o.*g)$". But, I want the middle part to only match the character sequence "o.*g", not an 'o' followed by a 'g' sometime later.
Anyone know how to do this? (As a brute force strategy, I could surround each letter in the user string with '[' and ']', but that seems ugly, especially since I'd have to be careful with characters like '^'.)
-mt
pgpbFl8SOftMR.pgp
Description: PGP signature
[Prev in Thread] | Current Thread | [Next in Thread] |