Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Replace " with text

Last post 07-22-2009, 1:03 PM by habskilla. 2 replies.
Sort Posts: Previous Next
  •  07-22-2009, 11:29 AM 55353

    Replace " with text

    Here is an example of the input text

    <Node id="ID0" class="rulegroup" name="Variable text" toplevel="true" type="cisco_ios">

     Example of output text

    <Node id="ID0" class="rulegroup" name="Variable text-Prod" toplevel="true" type="cisco_ios">

    Second example:

    <ServerNode id="ID0" oid="-11ww3effd" class="rule" name="Variable text" toplevel="true" type="linuxServer">

    <ServerNode id="ID0" oid="-11ww3effd" class="rule" name="Variable text-Prod" toplevel="true" type="linuxServer"> 

    Rules:

    Whenever you find  class="rulegroup" name=" or class="rule" name=" I need to append -Prod to the name.

    I can use either Ultraedit or a Windows GNU utility.

  •  07-22-2009, 12:32 PM 55354 in reply to 55353

    Re: Replace " with text

    Using Ultraedit with Perl regular expression engine checked, you can do a replace like this

    (?=<[^<>]*class="(?:rulegroup|rule)")(<[^<>]+name="[^"]+)

    replace with

    \1-Prod


    http://portal-vreme.ro
  •  07-22-2009, 1:03 PM 55355 in reply to 55354

    Re: Replace " with text

    I'm impressed.  Worked like a charm.

    Thanks!

    Now I have a great template to adapt to other situations where the parameters are a little different.

View as RSS news feed in XML