[jboss-dev] Regular expression for key value pairs
David M. Lloyd
david.lloyd at redhat.com
Fri Sep 4 12:21:50 EDT 2009
Splitting via regex is usually not a very good way to tokenize. If you
want to do a regex-based tokenizer, you'd probably create a pattern which
matches, in alternation, all the different possible tokens as separate
capture groups (written in such a way that any non-matching text causes the
overall pattern match to fail). Then your code can use Matcher.find() in a
loop, and whichever matcher.group() is populated, that's the matched token.
Of course that's a bit of a pain as well. :-)
Doing this via split doesn't work well because the "" strings can contain
commas, as well as various escape sequences, among other issues.
- DML
On 09/04/2009 11:09 AM, Vladimir Blagojevic wrote:
> Hi,
>
> What would be a regular expression for Java annotation key value pairs?
> I want to compile this regex in Pattern class and then call method split
> to get the the key value pairs. For example,
> @RequestForEnhancement(
> id = 2868724,
> synopsis = "Enable time-travel",
> engineer = "Mr. Peabody",
> date = "4/1/3007"
> )
>
> Much appreciated,
> Vladimir
> _______________________________________________
> jboss-development mailing list
> jboss-development at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-development
More information about the jboss-development
mailing list