Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Thanked 0 Times in 0 Posts

    Find and replace xml/html tag using regular expression


    I am new and wonder whether this is the proper location post my request, so please bear with me.

    I have the following block of text inside an xml file and I am trying to use regex to replace the following portion of it: "<p class="- topic/p ">

    <b class="+ topic/ph hi-d/b ">NOTE-</b>
    with "<note othertype="example" type="other" class="- topic/note ">" and also replace the closing tag with the appropriate tag in this case "</note>"instead of </p>.

    The pattern of the block of text is always starts with <p..> tag and carriage return or new line and then comes the next portion.

    So as you can see my objective is to replace the opening tag <p Ö.> including the text that follows it. And then jump any number of text or line to the closing tag </p> and replace it.

    Using my tools (Dreamweaver CS4, Programmerís Notepad), I am able to find portion of the target tag and text but I am not able to successfully replace.

    Here is the target block of text:

    <p class="- topic/p ">

    <b class="+ topic/ph hi-d/b ">NOTE-</b>(Number), PROCEED (direction)-BOUND, (other instructions or guidance), when<ol class="- topic/ol ">

    <li audience="mylist()" class="- topic/li ">HEADING (degrees), (other instructions as necessary).</li>



    I hope I am making sense with my request.

    Thank you for your help.

  2. AdSlot6
  3. #2
    New to the CF scene
    Join Date
    Oct 2011
    Thanked 0 Times in 0 Posts

    Post Found a way to do the replacement using Regex (Perl)

    Hello everyone,

    I have been trying different ways to solve my problem and I just managed to achieve what I needed. I am posting my solution for all the experts out there to help refine it if necessary. Or just in case it might be of help to someone else trying to do the same.

    Here is my regex:

    And the replacement is the following using captured group:

    \n<note othertype="example" type="other" class="- topic/note "> $2 </note>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts