Jump to content

StringRegexpReplace with pattern position reset?


Iczer
 Share

Recommended Posts

I need to clean up text with xml tags from some attributes. Problem is - the random order those attributes placed. It would be simple if use 1 regexp for 1 attribute clearance, but it's not effective. So target is one complex pattern:

to clear attributes attr7,attr2 and attr5 from :

"<xmlTag attr0="aaa" attr1="bbb" attr2="ccc" attr3="ddd" attr4="eee" attr5="fff" attr6="ggg" attr7="hhh" attr7="iii" />"

Not working:

$sPreFilter = StringRegExpReplace(ClipGet(),"(?si)(\A.+?<xmlTag[^>]+?)(\attr7=[\x22\x27\x60][^\x22\x27\x60]++[\x22\x27\x60]|attr2=[\x22\x27\x60][^\x22\x27\x60]++[\x22\x27\x60]|attr5=[\x22\x27\x60][^\x22\x27\x60]++[\x22\x27\x60])([^>]+?>.+\z)","$1 $3")

Is it possible use (and how) reset start of match "\K" for it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...