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 2007/07/19 07:02:43 UTC
regex text out of a file
I need help with this task:
I have an HTML file with this snippet:
<!-- begin includes -->
<script src="scripts/script1.js" />
<script src="scripts/script2.js" />
<script src="scripts/script3.js" />
<!-- end includes -->
I would like to get each the src attribute value of each script tag, e.g.
"scripts/script1.js, scripts/script2.js, scripts/script3.js "
After I extract the scripts I would like to be able to pass them another ant
task in my build file as a fileset or something.
I'm pretty sure I'm going to have to write my own task, because this is not
a very generic operation. But, can anybody think of any way I can use any
existing tasks out there to do this for me?
Thank,
Alex
Re: regex text out of a file
Posted by Dominique Devienne <dd...@gmail.com>.
On 7/20/07, Alex Egg <eg...@gmail.com> wrote:
> All I want to do is get the value of the 'src' attribute, how would a
> replaceregex help me?
I'm sorry, but I don't have the time to give you the solution, only
guide you as best I can...
<replaceregex pattern="(\d+) @{pattern}.*" replace="\1" />
The pattern *captures* only the part of the line of interest (using
the parens), and replace the whole line with that capture, in the
replace attribute, with \1, i.e. the first capture. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: regex text out of a file
Posted by Alex Egg <eg...@gmail.com>.
All I want to do is get the value of the 'src' attribute, how would a
replaceregex help me?
On 7/20/07, Dominique Devienne <dd...@gmail.com> wrote:
>
> > How can I get the src attribute values from this:
> > <!-- begin includes -->
> > <script src="scripts/script1.js" />
> > <script src="scripts/script2.js" />
> > <script src="scripts/script3.js" />
> > <!-- end includes -->
>
> Using a <tokenfilter><replaceregex>, as the link I provided shows. --DD
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
Re: regex text out of a file
Posted by Dominique Devienne <dd...@gmail.com>.
> How can I get the src attribute values from this:
> <!-- begin includes -->
> <script src="scripts/script1.js" />
> <script src="scripts/script2.js" />
> <script src="scripts/script3.js" />
> <!-- end includes -->
Using a <tokenfilter><replaceregex>, as the link I provided shows. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: regex text out of a file
Posted by Alex Egg <eg...@gmail.com>.
This is what I have so far:
<loadfile property="includeTags"
srcFile="${basedir}/management/default.aspx" >
<filterchain>
<linecontainsregexp>
<regexp pattern="<script"/>
</linecontainsregexp>
</filterchain>
</loadfile>
<echo>${includeTags}</echo>
How can I get the src attribute values from this:
<!-- begin includes -->
<script src="scripts/script1.js" />
<script src="scripts/script2.js" />
<script src="scripts/script3.js" />
<!-- end includes -->
On 7/19/07, Dominique Devienne <dd...@gmail.com> wrote:
>
> http://marc.info/?l=ant-user&m=113259283417972&w=2
>
> I searched for loadfile at this mailing archive site. --DD
>
>
> On 7/19/07, Alex Egg <eg...@gmail.com> wrote:
> > I looked at file reader to open the file, but can you show me an example
> of
> > the regex FileReader?
> >
> > On 7/19/07, Dominique Devienne <dd...@gmail.com> wrote:
> > >
> > > <loadfile> with a regex FilterReader can give you a property that
> > > contains only the scipt source files. You can then use the property in
> > > a <fileset> includes attribute, providing the proper dir to look for
> > > the files. --DD
> > >
> > > On 7/19/07, Alex Egg <eg...@gmail.com> wrote:
> > > > I need help with this task:
> > > > I have an HTML file with this snippet:
> > > >
> > > > <!-- begin includes -->
> > > > <script src="scripts/script1.js" />
> > > > <script src="scripts/script2.js" />
> > > > <script src="scripts/script3.js" />
> > > > <!-- end includes -->
> > > >
> > > > I would like to get each the src attribute value of each script tag,
> e.g
> > > .
> > > > "scripts/script1.js, scripts/script2.js, scripts/script3.js "
> > > >
> > > > After I extract the scripts I would like to be able to pass them
> another
> > > ant
> > > > task in my build file as a fileset or something.
> > > >
> > > > I'm pretty sure I'm going to have to write my own task, because this
> is
> > > not
> > > > a very generic operation. But, can anybody think of any way I can
> use
> > > any
> > > > existing tasks out there to do this for me?
> > > >
> > > > Thank,
> > > > Alex
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
>
>
Re: regex text out of a file
Posted by Dominique Devienne <dd...@gmail.com>.
http://marc.info/?l=ant-user&m=113259283417972&w=2
I searched for loadfile at this mailing archive site. --DD
On 7/19/07, Alex Egg <eg...@gmail.com> wrote:
> I looked at file reader to open the file, but can you show me an example of
> the regex FileReader?
>
> On 7/19/07, Dominique Devienne <dd...@gmail.com> wrote:
> >
> > <loadfile> with a regex FilterReader can give you a property that
> > contains only the scipt source files. You can then use the property in
> > a <fileset> includes attribute, providing the proper dir to look for
> > the files. --DD
> >
> > On 7/19/07, Alex Egg <eg...@gmail.com> wrote:
> > > I need help with this task:
> > > I have an HTML file with this snippet:
> > >
> > > <!-- begin includes -->
> > > <script src="scripts/script1.js" />
> > > <script src="scripts/script2.js" />
> > > <script src="scripts/script3.js" />
> > > <!-- end includes -->
> > >
> > > I would like to get each the src attribute value of each script tag, e.g
> > .
> > > "scripts/script1.js, scripts/script2.js, scripts/script3.js "
> > >
> > > After I extract the scripts I would like to be able to pass them another
> > ant
> > > task in my build file as a fileset or something.
> > >
> > > I'm pretty sure I'm going to have to write my own task, because this is
> > not
> > > a very generic operation. But, can anybody think of any way I can use
> > any
> > > existing tasks out there to do this for me?
> > >
> > > Thank,
> > > Alex
> > >
> >
> > ---------------------------------------------------------------------
> > 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
Re: regex text out of a file
Posted by Alex Egg <eg...@gmail.com>.
I looked at file reader to open the file, but can you show me an example of
the regex FileReader?
On 7/19/07, Dominique Devienne <dd...@gmail.com> wrote:
>
> <loadfile> with a regex FilterReader can give you a property that
> contains only the scipt source files. You can then use the property in
> a <fileset> includes attribute, providing the proper dir to look for
> the files. --DD
>
> On 7/19/07, Alex Egg <eg...@gmail.com> wrote:
> > I need help with this task:
> > I have an HTML file with this snippet:
> >
> > <!-- begin includes -->
> > <script src="scripts/script1.js" />
> > <script src="scripts/script2.js" />
> > <script src="scripts/script3.js" />
> > <!-- end includes -->
> >
> > I would like to get each the src attribute value of each script tag, e.g
> .
> > "scripts/script1.js, scripts/script2.js, scripts/script3.js "
> >
> > After I extract the scripts I would like to be able to pass them another
> ant
> > task in my build file as a fileset or something.
> >
> > I'm pretty sure I'm going to have to write my own task, because this is
> not
> > a very generic operation. But, can anybody think of any way I can use
> any
> > existing tasks out there to do this for me?
> >
> > Thank,
> > Alex
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
Re: regex text out of a file
Posted by Dominique Devienne <dd...@gmail.com>.
<loadfile> with a regex FilterReader can give you a property that
contains only the scipt source files. You can then use the property in
a <fileset> includes attribute, providing the proper dir to look for
the files. --DD
On 7/19/07, Alex Egg <eg...@gmail.com> wrote:
> I need help with this task:
> I have an HTML file with this snippet:
>
> <!-- begin includes -->
> <script src="scripts/script1.js" />
> <script src="scripts/script2.js" />
> <script src="scripts/script3.js" />
> <!-- end includes -->
>
> I would like to get each the src attribute value of each script tag, e.g.
> "scripts/script1.js, scripts/script2.js, scripts/script3.js "
>
> After I extract the scripts I would like to be able to pass them another ant
> task in my build file as a fileset or something.
>
> I'm pretty sure I'm going to have to write my own task, because this is not
> a very generic operation. But, can anybody think of any way I can use any
> existing tasks out there to do this for me?
>
> Thank,
> Alex
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: regex text out of a file
Posted by Brian Agnew <br...@oopsconsultancy.com>.
If your HTML file is (or can be converted to - using HTMLTidy or
similar) XHTML, then XMLTask may be of use:
http://www.oopsconsultancy.com/software/xmltask/
Particularly the <call> mechanism in the above.
Brian
Alex Egg wrote:
> I need help with this task:
> I have an HTML file with this snippet:
>
> <!-- begin includes -->
> <script src="scripts/script1.js" />
> <script src="scripts/script2.js" />
> <script src="scripts/script3.js" />
> <!-- end includes -->
>
> I would like to get each the src attribute value of each script tag, e.g.
> "scripts/script1.js, scripts/script2.js, scripts/script3.js "
>
> After I extract the scripts I would like to be able to pass them
> another ant
> task in my build file as a fileset or something.
>
> I'm pretty sure I'm going to have to write my own task, because this
> is not
> a very generic operation. But, can anybody think of any way I can use any
> existing tasks out there to do this for me?
>
> Thank,
> Alex
>
--
Brian Agnew http://www.oopsconsultancy.com
OOPS Consultancy Ltd brian @ oopsconsultancy.com
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org