I finally got it to work using <filetokenizer>. It converted everything in
such a way that I could recognize "\n" with the regex "[\n\r]+";
consequently, now I can perform multiline search/replaces. I tried the
flags="s", before posting to this mailing list, but I couldn't get it work
either. I don't think ant regex likes the newline character that editors
produce. Although I spent of time figuring it out, it is working fine now.
The plus side is that I read a lot of help pages on regular expressions
hoping to find the answer, which I didn't, but I learned a lot about regular
expressions and "ant" itself! The negative side is that I decided that what
I was doing was unnecessary because it was complicating the build process so
I dropped the whole idea; embedding examples inside of resource files would
only confuse people. I simply created a "Readme.txt" file to explain how to
setup resources instead. I allow comments because resource files can be
documented.

Well, i'm glad that tribulation is over!

Thanks,

-----Original Message-----
From: Peter Reilly [mailto:[EMAIL PROTECTED]
Sent: Friday, June 15, 2007 11:29 AM
To: Ant Users List; [EMAIL PROTECTED]
Subject: Re: replaceregex


You normally need the "s" flag to get the
pattern to match "\n": from the manual:
"""
s : Singleline. Treat the string as a single line of input, using "."
to match any character, including a newline, which normally, it would
not match.
"""

Peter

On 6/15/07, Erica A Ramsey <[EMAIL PROTECTED]> wrote:
> 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:[EMAIL PROTECTED]
> Sent: Thursday, June 14, 2007 10:20 PM
> To: Ant Users List; [EMAIL PROTECTED]
> 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:[EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.17/850 - Release Date: 6/15/2007
11:31 AM

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.17/850 - Release Date: 6/15/2007
11:31 AM


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to