Re: Pattern extracting




"Hendrik Maryns" <hendrik_maryns@xxxxxxxxxxxxx> wrote in message news:dvu503$2pt$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

Joni schreef:
Hello

I have a string which has this format

[TagName "Value"]

[...]

Pattern tagPattern = Pattern.compile("\[(\S*)\s+\"(.*)\"\]");
// you can replace \s+ by ' ' if you're sure it is exactly one space.
// be careful when replacing \S*, if you use .*, you'll probably need a
// non-greedy quantifier.


What about the second .* that appears between the double-quote marks? Shouldn't that be non-greedy as well (or replaced with \S* as well)?

- Oliver

.