You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-user@jakarta.apache.org by Pete Carapetyan <pe...@datafundamentals.com> on 2002/07/17 17:26:47 UTC
Multiple matching - may not have done this the correct way.
This works fine, but may not be the way regexp was designed to be used.
I would appreciate any comments that can direct me to better ways to do
this.
This is the guts of pseudocode for a tag substitution program that goes
through files, finds all the tags, and does the right thing with the
tags portion, while just passing the rest through unchanged.
int startPrint = 0;
int tagStart = 0;
int tagEnd = 0;
aString = "a string of some long sort, mostly miles of text from
files";
RE reg = new RE("aTagMatch");
for(int i = 0;reg.match(aString,tagEnd+1);i++){
startPrint=tagEnd;
tagStart=reg.getParenStart(0);
tagEnd=reg.getParenEnd(0);
System.out.println(aString.substring(startPrint,tagStart));
System.out.println(i+ " startPrint = "
+ startPrint + " tagStart = "
+ tagStart+ " tagEnd = "
+ tagEnd + " Test String was '"
+ reg.getParen(0) + "'");
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>