mercredi 25 février 2015

target a specific part of code and change it


I have the following html code



<td style="color:#8C8C8C;font-size:10px;font-family:Arial,'Helvetica';text-align:center; padding:0 15px 0 15px;">Keep ensured your hat is fine.<br />
If you are having issues <a style="color:#8C8C8C;" target="_blank" href="#"><u>together</u></a>.</td>


I need to replace the above with only



<td style="color:#8C8C8C;font-size:10px;font-family:Arial,'Helvetica';text-align:center; padding:0 15px 0 15px;">[|blank|] <a style="color:#8C8C8C;" target="_blank" href="#"><u> together </u></a>.</td>


I'm specifically targeting this part and want to remove only this part



Keep ensured your hat is fine.<br />
If you are having issues


As you can see , I have line feed , space etc.


A friend of mine helped me out with this



perl -0777pe "s/<td style=\"color:#8C8C8C;font-size:10px;font-family:Arial,'Helvetica';text-align:center; padding:0 15px 0 15px;\">\K.*?(?=<a\b)/[|blank|] /sg"


But I want only the specific part searched and removed.


I'm a real perl newbie so any help would be welcomed.



Aucun commentaire:

Enregistrer un commentaire