Re: Trouble with regular expressions
- From: laredotornado <laredotornado@xxxxxxxxxxx>
- Date: Wed, 29 Jul 2009 10:37:04 -0700 (PDT)
On Jul 29, 10:48 am, markspace <nos...@xxxxxxxxxxx> wrote:
laredotornado wrote:
The assertion ("m1.matches") fails, even though "pageString.indexOf"
returns a value greater than -1, indicating the string is found. So
I'm missing something fundamental about regular expressions.
m1.matches() means "the regex matches the WHOLE STRING", not some
portion of it.
Use m1.region(int start, int end) to restrict the matches() method to
one part of your input string.
Or use find() (or lookingAt()) to match substrings (indexOf() uses
find(), I believe).
Indeed, when I changed to "find" instead of "matches", everything
worked out great. 5 stars. - Dave
.
- Follow-Ups:
- Re: Trouble with regular expressions
- From: markspace
- Re: Trouble with regular expressions
- References:
- Trouble with regular expressions
- From: laredotornado
- Re: Trouble with regular expressions
- From: markspace
- Trouble with regular expressions
- Prev by Date: Re: bit operations and parity
- Next by Date: Re: bit operations and parity
- Previous by thread: Re: Trouble with regular expressions
- Next by thread: Re: Trouble with regular expressions
- Index(es):
Relevant Pages
|