Find text chunk with tags, tabs, line endings- use wildcard?

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
kiblinger
Forum Newbie
Posts: 1
Joined: Sat Jul 21, 2007 7:12 pm

Find text chunk with tags, tabs, line endings- use wildcard?

Post by kiblinger »

I am working in a VBScript / JavaScript ECMA-262 regular expression environment:

I have something like:

Code: Select all

           <attr>
                <attrlabl>SUBBASIN</attrlabl>
            </attr>
 
or:

Code: Select all

           <attr>
                <attrlabl>SUBBASIN</attrlabl>
                <attrdef>XYZPDQ</attrdef><attrdefs>ABCDEFG</attrdefs></attr>

and I want to do this:

FIND:

Code: Select all

<attr>  ---ANYTHING---  <attrlabl>SUBBASIN</attrlabl>  ---ANYTHING---  </attr>
REPLACE WITH:

Code: Select all

<attr> <attrlabl>SUBBASIN</attrlabl>   <newtag>Other Stuff</newtag> <anothertag>More stuff</anothertag>   </attr>
 
I thought

Code: Select all

<attr>*<attrlabl>SUBBASIN</attrlabl>*</attr>
would work but it doesn't. I am stumped; \s seems to maybe be involved to account for various \t \r and \n characters but I still can't get a wildcard to capture all the other stuff.
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Find text chunk with tags, tabs, line endings- use wildcard?

Post by prometheuzz »

This doesn't seem to be PHP related and cross posted here:

http://regexadvice.com/forums/thread/47237.aspx
Post Reply