a question of using regular expression

Tom Davies tomdavies at optushome.com.au
Wed Nov 28 03:16:40 EST 2001


"Stephen" <fungho at sinaman.com> wrote in message
news:b551ef53.0111272346.68222906 at posting.google.com...
> I am now using org.apache.regexp as the regular expression library in
> my Java code. I meet a difficulty in implementating the following
> regular expression, I don't know how to describe it (because of my
> poor English), so I take an example:
>
> String sText0 = "good morning!";
> String sText1 = "morning! you are very good!";
>
> RE r = new RE("???????????"); // I have no idea in this
>
> actually, I just want to get the string which has string "good" at the
> start. Therefore, in this case, sText0 can be got only. How can I do
> this? Thanks!

What is it about that string which makes it match? If you want 'all strings
which start with "good"', then something like:

[start of line]good[any character][0 or more repetitions] would work.

In java.util.regex this would be "^good.*"

Tom





More information about the Python-list mailing list