You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-dev@jakarta.apache.org by Jörgen Kosche <jk...@mnementh.de> on 2004/07/25 18:09:28 UTC

Patch for Regexp

Hello

For some reason I need to match strings from the beginning of an
input-string and I dont want to load this string completely (from a file
or URL) if not needed. That should be possible, because the match
can be cancelled, if the first characters dont match.

Regexp doesn't do this, also if I start the regexp with a '^' and
activate the Flag MATCH_SINGLELINE. So I added a new flag to
match from the beginning of the string and stops, if the first
characters do not match. That also enhances the performance,
if the regexp dont match on a very long input-string.
To demonstrate this, I added the Performance.java that makes some
matches on very long strings.

I added in the patchtxt file the patch for RE.java itself, as created by
'cvs diff'.

Hope this patch will be helpful not only for me. Keep on the good work
on the regexp-library. Excuse my bad english, I'm not a native
english-speaker.

Ciao, Jörgen Kosche
-- 
Jörgen 'Mnementh' Kosche
jkosche@mnementh.de
GPG: http://www.mnementh.de/public_key
Webseite: http://www.mnementh.de/

Re: Patch for Regexp

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Jörgen Kosche wrote:
> Hello again
> 
> I forgot one thing in the last mail:
> In the program Performance.java reset the line:
> RE re = new RE("xyz", RE.MATCH_FROMBEGINNING);
> with:
> RE re = new RE("^xyz", RE.MATCH_SINGLELINE);
> 
> That should have the same effect, but the second variety is much
> slower, because it try to match on the whole string.

Jörgen,

1.4 release has optimization for "^xyz", try it out.

Regards,
Vadim

---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-dev-help@jakarta.apache.org


Re: Patch for Regexp

Posted by Jörgen Kosche <jk...@mnementh.de>.
Hello again

I forgot one thing in the last mail:
In the program Performance.java reset the line:
RE re = new RE("xyz", RE.MATCH_FROMBEGINNING);
with:
RE re = new RE("^xyz", RE.MATCH_SINGLELINE);

That should have the same effect, but the second variety is much
slower, because it try to match on the whole string.

Jörgen
-- 
Jörgen 'Mnementh' Kosche
jkosche@mnementh.de
GPG: http://www.mnementh.de/public_key
Webseite: http://www.mnementh.de/