Re: Prefixes of regular expressions
- From: David Segall <david@xxxxxxxxxxxxxxx>
- Date: Mon, 30 Jun 2008 16:00:48 GMT
S J Kissane <skissane@xxxxxxxxx> wrote:
Suppose I have a regular expression defined like this: [0-9A-F]{8}I can see that your putative changes to Matcher provides an elegant
Now, the question is, given a regular expression and a string,
how in Java can I determine if the string is a valid prefix of
the regular expression? I have looked at the java.util.regex.Matcher
API in Java SE 6, and I can't see a way of doing this.
solution to your problem but they would require changing some return
values from boolean to something containing more information. Rather
than altering Java's method(s) or having multiple regular expressions
to test for your three return values perhaps you could append a valid
string of the appropriate length to the input as a second test. In
your example, this approach is worse than using a second regular
expression to check for a valid prefix but it may provide an easier
general solution.
.
- References:
- Prefixes of regular expressions
- From: S J Kissane
- Prefixes of regular expressions
- Prev by Date: Question on JavaScript
- Next by Date: Re: Limiting RMI to localhost
- Previous by thread: Re: Prefixes of regular expressions
- Next by thread: advantages of shorthand operator
- Index(es):
Relevant Pages
|