ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick (Gus) Heck" <patrick.h...@olin.edu>
Subject Re: Problems with ReplaceRegex
Date Fri, 21 Jun 2002 16:12:39 GMT
I am guessing that the problem is you don't want to leave the \r\n
behind.

One way to deal with this is to simply do multiple match/replace
operations.

First delete the string if it matches,
Then delete \r if it matches.
then delete \n if you get a match for it.

If either of the terminators is mot there, it doesn't match and nothing
happens. This handles an eof without a newline too.

Granted this is probably slower, and requries more typing, but perhaps
less typing than debugging cross platform regexps in Ant :).

Gus


Lou Fox wrote:
> 
> The problem is strictly the end of line termination character.  If I leaves
> off the \r\n it will match all of the line except the \r\n at the end of the
> line.  The $ acts as if there isn't a \r\n in the regular expression, and
> thus matches the entire line except the \r\n at the end of the line as well.
> I was hoping that the author, Mathew Inger would look into this, but I'm
> going to try to debug it myself.  It'll be a great learning experience since
> I never debugged an application this large before.
> 
> ----- Original Message -----
> From: "Steven Newton" <snewton@standard.com>
> To: "Ant Developers List" <ant-dev@jakarta.apache.org>; "Lou Fox"
> <foulox@yahoo.com>
> Sent: Thursday, June 20, 2002 4:36 PM
> Subject: RE: Problems with ReplaceRegex
> 
> It should be fairly straightforward to resolve, though I recommend
> getting a good reference on regexes if you're going to be doing
> this thing a lot.
> 
> First, instead of \r\n use $, this will match the end of line no matter
> what platform.  Second, I'm guessing the other two backslashes in the
> expression need to be escaped out.  So, try this one:
> 
>    match="^.*\\.(gif|jpg|js|ram)\\^.*$"
> 
> s
> 
> > -----Original Message-----
> > From: Lou Fox [mailto:loufox@cloud9.net]
> > Sent: Thursday, June 20, 2002 11:23 AM
> > To: ant-dev@jakarta.apache.org
> > Subject: Problems with ReplaceRegex
> >
> >
> > I've been trying to get this replaceregex to work for several
> > days now without any progress.  I even wrote the exact same
> > regex in perl and it worked just fine, could someone please
> > look into this for me.
> > Here is the replaceregexp that I'm using:
> >   <fileset id="unzippedfiles" dir="${tmpdir}" />
> >   <replaceregexp
> >    byline="true"
> >    flags="i"
> >    match="^.*\.(gif|jpg|js|ram)\^.*\r\n"
> >    replace="">
> >    <fileset refid="unzippedfiles" />
> >   </replaceregexp>
> >
> > Currently it doesn't match at all.  If I remove the \r\n,
> > then it removes the text from the line, and leaves the \r\n.
> > Adding the flags="s" doesn't change the behavior at all.
> > Using \\r\\n or \n or \\n doesn't match at all.
> >
> > My CLASSPATH is
> > .\;D:\java\jakarta-oro-2.0.6\jakarta-oro-2.0.6.jar;D:\java\xer
> > ces-2_0_1\tools\xerces.jar;d:\j2sdk1.4.0\jre\lib\rt.jar
> >
> >
> >
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message