Monday, November 17, 2014

How to replace HTML tag with ant

To replace a word or character with Ant,
we can use the following command.

<replaceregexp file="{FILE_TO_REPLACE}"
    match="{WORD_TO_REPLACE}"
    replace="{WORD}" flags="g" byline="true" />

But the above command can use to replace words withouth xml/html reserved characters only.
To replace words with xml/html reserved characters,

Steps:
1. encode the xml/html reserved words before putting into the the <replaceregexp /> command.
eg, <a>link</link>  =>  &lt;a&gt;link&lt;/a&gt;

2. put the encoded words into <replaceregexp />
eg,

<replaceregexp file="{FILE_TO_REPLACE}"
    match="&lt;a&gt;link&lt;/a&gt;"
    replace="&lt;a&gt;new_link&lt;/a&gt;" flags="g" byline="true" />


Done!!

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...