regex - How can I replace text that is not part of an anchor tag in Perl? -


What is a Pearl regex that can replace a selected text which is not part of an anchor tag? For example, I would like to replace only the last "text" in the following code.

  blah & lt; A href = "http://www.text.com" & gt; Blah text blah & lt; / A & gt; Blah Blah Bless  

Thank you.

Try parsing HTML with a regex instead you do not want to try.

  Use HTML :: TreeBuilder; My $ html = HTML :: TreeBuilder-> new_from_file ('file.html'); # Or some other method, depending on what your HTML is ($ html); Sub-doReplace {my $ elt = shift; Do this before my $ node ($ elt-> content_refs_list) (if (refred $$ node)) $$ node- until $ doreplace ($$ node); Tag eq 'a'; } And {$$ node = ~ s / text / replace / g; } This is a text node ending in #. # End foreach $ node} #and done replay  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -