notepad++ - Search/Replace (in an XML-File) the value of one attribute if another attribute has a specific value -
my xml file (~6000 lines) contains lines these:
<sms protocol="0" address="+12341234" date="12341234" type="2" subject="null" body="smstext" toa="0" sc_toa="0" service_center="+12341234" read="1" status="-1" locked="0" date_sent="null" readable_date="jan 6, 1980 1:02:14 am" contact_name="patrick" /> and want replace text of contact_name else, if type="2".
i mean easy if bookmark type="2" lines , search/replace on bookmarked lines only, haven't found such option.
so how in notepad++?
edit: changed title, meant attribute not tag ...
you can try following:
find: (?<=type="2")(.*?)(contact_name=")(.*?)(")
replace with: \1\2someothercontactname\4
(?<=type="2") let's see if string contains type="2", not capturing string
(.*?) first group between type , contact name (any symbol)
(contact_name=") - second group
(.*?) group #3 wicth want replace other value (any symbol, or can [a-za-z]
(") - contains closing quote. , use group 4 in replace statement
Comments
Post a Comment