You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Alex Egg <eg...@gmail.com> on 2006/07/17 09:33:49 UTC

ReplaceRegExp Task and line breaks

Hi,

I'm using the replaceRegexp ant task and I want to replace whatever matches
my pattern with 2 line breaks.

Right now I'm doing this:

     <replaceregexp
            match="(?&lt;=&lt;\/method&gt;)\s*(?=^[\t ]*&lt;method)"
            replace="\n\n"
            flags="gmi"
            encoding="UTF-8"
    >
            <fileset dir="." includes="${xml.include}" />
    </replaceregexp >

however, it replace the file with the \n\n as literal text. How can I
replace these w/ 2 line breaks?

Re: ReplaceRegExp Task and line breaks

Posted by Alex Egg <eg...@gmail.com>.
Yeah, that works:

> I just used the lf ascii code and that works:
>
>      <replaceregexp
>             match="(?&lt;=&lt;\/method&gt;)\s*(?=^[\t ]*&lt;method)"
>             replace="&#10;&#10;"
>             flags="gmi"
>             encoding="UTF-8"
>     >
>             <fileset dir="." includes="${xml.include}" />
>     </replaceregexp >

On 7/18/06, Aaron Davies <aa...@gmail.com> wrote:
>
> Oops, that should of course be &lf;.
>
> On 7/18/06, Aaron Davies <aa...@gmail.com> wrote:
> > How about using entities? Are &#10; or &#xA; or &#lf; defined in the
> > XML dialect we're using?
> >
> > On 7/18/06, Stefano Marsili <rs...@yahoo.com> wrote:
> > > I strongly doubt it's the easiest way to achieve what
> > > you want, but you could write a script or define a
> > > scriptdef that writes the \n (0x0A) to a property and
> > > use it. Anyway, if you want your build to be platform
> > > indipendent, I think ${line.separator} is still the
> > > best choice.
> > >
> > > Stefano Marsili
> > > PFunctions: http://www.efanomars.net/pf
> > >
> > > --- Alex Egg <eg...@gmail.com> wrote:
> > >
> > > > Hi,
> > > >
> > > > I think some of your message got cut off... Is there
> > > > any way you can think
> > > > of to specify the line break literally in the xml
> > > > attribute?
> > > >
> > > > (Using the line.separator property works by the
> > > > way!)
> > > >
> > > > Thanks,
> > > > Alex
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > >
> > >
> >
> >
> > --
> > Aaron Davies
> > aaron.davies@gmail.com
> >
>
>
> --
> Aaron Davies
> aaron.davies@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Re: ReplaceRegExp Task and line breaks

Posted by Aaron Davies <aa...@gmail.com>.
Oops, that should of course be &lf;.

On 7/18/06, Aaron Davies <aa...@gmail.com> wrote:
> How about using entities? Are &#10; or &#xA; or &#lf; defined in the
> XML dialect we're using?
>
> On 7/18/06, Stefano Marsili <rs...@yahoo.com> wrote:
> > I strongly doubt it's the easiest way to achieve what
> > you want, but you could write a script or define a
> > scriptdef that writes the \n (0x0A) to a property and
> > use it. Anyway, if you want your build to be platform
> > indipendent, I think ${line.separator} is still the
> > best choice.
> >
> > Stefano Marsili
> > PFunctions: http://www.efanomars.net/pf
> >
> > --- Alex Egg <eg...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > I think some of your message got cut off... Is there
> > > any way you can think
> > > of to specify the line break literally in the xml
> > > attribute?
> > >
> > > (Using the line.separator property works by the
> > > way!)
> > >
> > > Thanks,
> > > Alex
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
>
>
> --
> Aaron Davies
> aaron.davies@gmail.com
>


-- 
Aaron Davies
aaron.davies@gmail.com

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


Re: ReplaceRegExp Task and line breaks

Posted by Aaron Davies <aa...@gmail.com>.
How about using entities? Are &#10; or &#xA; or &#lf; defined in the
XML dialect we're using?

On 7/18/06, Stefano Marsili <rs...@yahoo.com> wrote:
> I strongly doubt it's the easiest way to achieve what
> you want, but you could write a script or define a
> scriptdef that writes the \n (0x0A) to a property and
> use it. Anyway, if you want your build to be platform
> indipendent, I think ${line.separator} is still the
> best choice.
>
> Stefano Marsili
> PFunctions: http://www.efanomars.net/pf
>
> --- Alex Egg <eg...@gmail.com> wrote:
>
> > Hi,
> >
> > I think some of your message got cut off... Is there
> > any way you can think
> > of to specify the line break literally in the xml
> > attribute?
> >
> > (Using the line.separator property works by the
> > way!)
> >
> > Thanks,
> > Alex
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
Aaron Davies
aaron.davies@gmail.com

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


Re: ReplaceRegExp Task and line breaks

Posted by Stefano Marsili <rs...@yahoo.com>.
I strongly doubt it's the easiest way to achieve what
you want, but you could write a script or define a
scriptdef that writes the \n (0x0A) to a property and
use it. Anyway, if you want your build to be platform
indipendent, I think ${line.separator} is still the
best choice.

Stefano Marsili
PFunctions: http://www.efanomars.net/pf

--- Alex Egg <eg...@gmail.com> wrote:

> Hi,
> 
> I think some of your message got cut off... Is there
> any way you can think
> of to specify the line break literally in the xml
> attribute?
> 
> (Using the line.separator property works by the
> way!)
> 
> Thanks,
> Alex


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: ReplaceRegExp Task and line breaks

Posted by Alex Egg <eg...@gmail.com>.
Hi,

I think some of your message got cut off... Is there any way you can think
of to specify the line break literally in the xml attribute?

(Using the line.separator property works by the way!)

Thanks,
Alex

On 7/17/06, Scot P. Floess <fl...@mindspring.com> wrote:
>
> I think that should work.  Basically, I think the problem is that the
> XML attribute is being taken literally so \n is literally a backslash and
> n
>
> Stefano Marsili wrote:
> > Hi Alex,
> >
> > I didn't test it, but you could try
> >
> > replace="${line.separator}${line.separator}"
> >
> > Stefano Marsili
> > http://www.efanomars.net/pf
> >
> >
> > --- Alex Egg <eg...@gmail.com> wrote:
> >
> >
> >> Hi,
> >>
> >> I'm using the replaceRegexp ant task and I want to
> >> replace whatever matches
> >> my pattern with 2 line breaks.
> >>
> >> Right now I'm doing this:
> >>
> >>      <replaceregexp
> >>
> >> match="(?&lt;=&lt;\/method&gt;)\s*(?=^[\t
> >> ]*&lt;method)"
> >>             replace="\n\n"
> >>             flags="gmi"
> >>             encoding="UTF-8"
> >>     >
> >>             <fileset dir="."
> >> includes="${xml.include}" />
> >>     </replaceregexp >
> >>
> >> however, it replace the file with the \n\n as
> >> literal text. How can I
> >> replace these w/ 2 line breaks?
> >>
> >>
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> >
>
> --
> Scot P. Floess
> 27 Lake Royale
> Louisburg, NC  27549
>
> 252-478-8087 (Home)
> 919-754-4592 (Work)
>
> Chief Architect JPlate  http://sourceforge.net/projects/jplate
> Chief Architect JavaPIM http://sourceforge.net/projects/javapim
>
>
>

Re: ReplaceRegExp Task and line breaks

Posted by "Scot P. Floess" <fl...@mindspring.com>.
I think that should work.  Basically, I think the problem is that the 
XML attribute is being taken literally so \n is literally a backslash and n

Stefano Marsili wrote:
> Hi Alex,
>
> I didn't test it, but you could try 
>
> replace="${line.separator}${line.separator}"
>
> Stefano Marsili
> http://www.efanomars.net/pf
>
>
> --- Alex Egg <eg...@gmail.com> wrote:
>
>   
>> Hi,
>>
>> I'm using the replaceRegexp ant task and I want to
>> replace whatever matches
>> my pattern with 2 line breaks.
>>
>> Right now I'm doing this:
>>
>>      <replaceregexp
>>            
>> match="(?&lt;=&lt;\/method&gt;)\s*(?=^[\t
>> ]*&lt;method)"
>>             replace="\n\n"
>>             flags="gmi"
>>             encoding="UTF-8"
>>     >
>>             <fileset dir="."
>> includes="${xml.include}" />
>>     </replaceregexp >
>>
>> however, it replace the file with the \n\n as
>> literal text. How can I
>> replace these w/ 2 line breaks?
>>
>>     
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>   

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

252-478-8087 (Home)
919-754-4592 (Work)

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


Re: ReplaceRegExp Task and line breaks

Posted by Stefano Marsili <rs...@yahoo.com>.
Hi Alex,

I didn't test it, but you could try 

replace="${line.separator}${line.separator}"

Stefano Marsili
http://www.efanomars.net/pf


--- Alex Egg <eg...@gmail.com> wrote:

> Hi,
> 
> I'm using the replaceRegexp ant task and I want to
> replace whatever matches
> my pattern with 2 line breaks.
> 
> Right now I'm doing this:
> 
>      <replaceregexp
>            
> match="(?&lt;=&lt;\/method&gt;)\s*(?=^[\t
> ]*&lt;method)"
>             replace="\n\n"
>             flags="gmi"
>             encoding="UTF-8"
>     >
>             <fileset dir="."
> includes="${xml.include}" />
>     </replaceregexp >
> 
> however, it replace the file with the \n\n as
> literal text. How can I
> replace these w/ 2 line breaks?
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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