ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erica A Ramsey" <earam...@wideopenwest.com>
Subject RE: replaceregex
Date Fri, 15 Jun 2007 16:25:56 GMT
I think that I see the probem regex is not interpreting newline character
properly. I tryied pattern="[\x0a\x0d]+" and it did not find anything. Why
will it not find it?

-----Original Message-----
From: Erica A Ramsey [mailto:ericaramsey1@gmail.com]
Sent: Thursday, June 14, 2007 10:20 PM
To: Ant Users List; floess@mindspring.com
Subject: RE: replaceregex


well, I give up hopefully someone out there can help me. this was my last
try;
  <replaceregex pattern="^#example[\s|(?:^#)|.]+^#end example.*" replace=""
flags="g" />
I thought the pattern specified the following;
  lines that start with '#example'
  followed one or more of {whitespace OR (lines that do not start with '#')
OR any char}
  followed by lines that start with '#'
  followed by 'end example'
  followed by zero or more of [any character]
where 'whitespace' is in the set {\n\t }
but it does not delete the following sequence;
#example
F1
F2
$
.
#end example junk

I specified the greedy pattern, '.', last so it doesnt eat '#' before it is
excluded with the expression  (?:^#) which I think means exclude lines that
start with '#'. that way the pattern '^#end example.*', lines that start
with '^' followed by 'end example', does not get eaten by greedy '.'.
This is the complete thing I am trying to do.
		<copy overwrite="true" file="fields.txt" tofile="fields.rsc">
			<filterchain>
				<tokenfilter>
					<replaceregex pattern="^#example[\s|(?:^#)|.]+^#end example.*"
replace="" flags="g" />
					<replaceregex pattern="#.*" replace="" flags="g" />
					<deletecharacters chars="\t" />
					<trim />
					<ignoreblank />
				</tokenfilter>
			</filterchain>
		</copy>
everything but the first regex succeeds :(
basically it strips out comments and everything between '#example'  and
'#end example' including newlines. This allows  comments, and any examples,
to be stripped out during copy so that the resulting field.rsc file  doesn't
have any unneeded stuff in it. This file will then be included in the jar
archive. however, i'm stumped everything that I have tried has failed :(

-----Original Message-----
From: Scot P. Floess [mailto:floess@mindspring.com]
Sent: Thursday, June 14, 2007 3:57 PM
To: Ant Users List
Subject: Re: replaceregex


I don't mean to sound smart...but have you tried it?  Run a test?

It might be time better spent if you run a test, it fails then email the
list?

Erica Ramsey wrote:
> hello, will the following example replace everything between '#example
> ' and
> '#end example.*' ? I am trying to strip the following from a file;
>
> #example -- do not remove this line!
> test1 #comment
> test2
> $
> test3 #another comment
> .
> #end example -- do not remove this line!
>
> everything between '#example' and '#end example.*' must be stripped out.
>
> here is my expression:
> <replaceregex pattern="#example(\n.)+#end example.*" replace=""
> flags="g" />
>
> Thanks!
>

--
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-392-6730 (Work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.15/848 - Release Date: 6/13/2007
12:50 PM

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.15/848 - Release Date: 6/13/2007
12:50 PM


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.15/848 - Release Date: 6/13/2007
12:50 PM

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.16/849 - Release Date: 6/14/2007
12:44 PM


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message