ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: Regular expression matching
Date Fri, 21 Feb 2003 07:32:35 GMT
I don´t know the JSP 2 Syntax and I don´t know what (exactly) you want to
replace.
But I did a quick hack in perl:

Input:
----------------
<?xml version="1.0"?>
<jsp>
some stuff <c:test/> some stuff <c:out>print this</c:out> some 
stuff <c:test/> some stuff <c:out>print this</c:out> some stuff 
</jsp>

Output:
----------------
<?xml version="1.0"?>
<jsp>
some stuff <c:test/> some stuff ##print this## some 
stuff <c:test/> some stuff ##print this## some stuff 
</jsp>

Perl:
----------------
foreach (<STDIN>) {
	s/<c:out>/##/g;
	s/<\/c:out>/##/g;
	print;
}


So the RegExp are in Perl lines 2 + 3.

After Stefans hint for <replaceregexp> (I mist that at time of writing :-) I
did a search for that. It´s an optional task (not a filter where I did my
first search).

So the Target could be (not tested)

<target name="convert-JSP12-JSP2">
    <!-- Copy the files, because <replaceregexp> will modify the sources -->
    <copy todir="${jsp2.dir}">
        <fileset dir="${jsp12.dir}"/>
    </copy>

    <!-- Replace the start string -->
    <replaceregexp match="<c:out>" replace="##" byline="true">
        <fileset dir="${jsp2.dir}"/>
    </replaceregexp>

    <!-- Replace the end string -->
    <replaceregexp match="</c:out>" replace="##" byline="true">
        <fileset dir="${jsp2.dir}"/>
    </replaceregexp>
</target>


Jan Matèrne
	

> -----Ursprüngliche Nachricht-----
> Von: Matt Raible [mailto:matt@raibledesigns.com]
> Gesendet am: Freitag, 21. Februar 2003 08:13
> An: 'Ant Users List'
> Betreff: RE: Regular expression matching
> 
> I'm no reqular expression expert - anyone have a clue how to 
> replace my
> desired strings?
> 
> Thanks,
> 
> Matt
> 
> > -----Original Message-----
> > From: Jan.Materne@rzf.fin-nrw.de 
> [mailto:Jan.Materne@rzf.fin-nrw.de] 
> > Sent: Friday, February 21, 2003 12:07 AM
> > To: user@ant.apache.org
> > Subject: AW: Regular expression matching
> > 
> > 
> > Have you tried
> > 
> > <loadfile>
> > 	<filterchain/>
> > </loadfile>
> > 
> > 
> > You can write your own filter for doing the substitution, or 
> > write your JSP not mit <c:out> but with @out@, then you can 
> > use that as key and substitute it via <expandproperties/> or 
> > with <replacetokens> <token key="out" value="<c:out>"/> 
> > </replacetokens>. (not tested, but could work).
> > 
> > I think the best way is to write a <replaceregexp><regexp 
> > pattern="foo" substite="bar"/></>.
> > 
> > 
> > Jan Matèrne
> >   
> > 
> > 
> > > -----Ursprüngliche Nachricht-----
> > > Von: Matt Raible [mailto:matt@raibledesigns.com]
> > > Gesendet am: Freitag, 21. Februar 2003 03:59
> > > An: 'Ant Users List'
> > > Betreff: RE: Regular expression matching
> > > 
> > > Actually, what I'd like to do is be able to create a JSP 1.2
> > > version of
> > > my app (with c:out) and a JSP 2.0 (with c:out stripped 
> > out).  I'd like
> > > to have this as a switch when I run my build.xml.
> > > 
> > > Matt
> > > 
> > > > -----Original Message-----
> > > > From: Craig Berry [mailto:Craig.Berry@portblue.com]
> > > > Sent: Thursday, February 20, 2003 7:25 PM
> > > > To: Ant Users List
> > > > Subject: RE: Regular expression matching
> > > > 
> > > > 
> > > > If you're just talking about doing this once for the
> > > > codebase, I'd suggest using global substitution from your 
> > > > favorite IDE (Eclipse does this very well).  Or, if you're 
> > > > feeling old-school, use perl or sed or the like from the 
> > > command line.
> > > > 
> > > > -----Original Message-----
> > > > From: Matt Raible [mailto:matt@raibledesigns.com]
> > > > Sent: Thursday, February 20, 2003 3:57 PM
> > > > To: user@ant.apache.org
> > > > Subject: Regular expression matching
> > > > 
> > > > 
> > > > Is there a way that I can parse my .jsp files with a regexp
> > > > matching and convert all of:
> > > > 
> > > > <c:out value="${...}" />
> > > > 
> > > > to simply:
> > > > 
> > > > ${...}
> > > > 
> > > > I want to be able to produce a JSP 2.0 version of my app from
> > > > a JSP 1.2 codebase that uses JSTL.
> > > > 
> > > > Thanks,
> > > > 
> > > > Matt
> > > > 
> > > > 
> > > > 
> > > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > > For additional commands, e-mail: user-help@ant.apache.org
> > > > 
> > > > 
> > > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > > For additional commands, e-mail: user-help@ant.apache.org
> > > > 
> > > 
> > > 
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > > 
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message