Re: Prefixes of regular expressions
- From: S J Kissane <skissane@xxxxxxxxx>
- Date: Sun, 29 Jun 2008 14:01:50 -0700 (PDT)
On Jun 30, 1:12 am, "Arved Sandstrom" <asandst...@xxxxxxxxxxxxx>
wrote:
Define two regular expressions: one for valid (green), and one for validIndeed, such an approach would work. But, logically speaking, I only
prefix (yellow). Match the supplied string against the first; if matched,
display green. If no match, match against the second. If matched, display
yellow; if no match, display red. You lose nothing in responsiveness with
two regular expressions - this is a user-typed form field after all. And the
logic becomes more clear.
For some situations you could probably use groupCount() on the Matcher
object, with capturing groups, to distinguish between a valid prefix and a
valid complete string.
AHS
need
one regular expression to do this, not two. And by using two, I need
to manually
construct the prefix regex based on the whole string regex, when
logically
the former can be derived from the latter.
Maybe its time for a trip to bugs.sun.com... Who knows, I might see
the functionality
I'm after in J2SE 12.0 :)
Simon
.
- References:
- Prefixes of regular expressions
- From: S J Kissane
- Re: Prefixes of regular expressions
- From: Arved Sandstrom
- Prefixes of regular expressions
- Prev by Date: Re: Eckel criticism
- Next by Date: Re: Eckel criticism
- Previous by thread: Re: Prefixes of regular expressions
- Next by thread: Re: Prefixes of regular expressions
- Index(es):
Relevant Pages
|