Sublime text xml replace regex result -
i have problem replacing regex result in multiple xml tags in sumbilme text.
i have xml code multiple tags <startdate>
in different groups this:
<group1> <id>123</id> <startdate>2011-11-11</startdate> <city>new york</city> . . </group1> <group2> <id>456</id> <startdate>2013-10-01</startdate> <classcode>123</classcode> . . </group2> <group1> <id>789</id> <startdate>2016-01-17</startdate> <city>washington</city> . . </group1> <group2> <id>135</id> <startdate>2013-12-22</startdate> <classcode>234</classcode> . . </group2>
i replace every tag <startdate>(...some date...)</startdate>
in <group2>
<startdate1>(...some date...)</startdate1>
text in brackets (...some date...) different.
i started find tags , used code:
(?=.*<startdate>)(?=.*</startdate> <classcode>)
and works. sublime found every tag <startdate>(...some date...)</startdate>
in <group2>
. have problem replace text in founded tags.
i tried put code 'replace' line:
(?=.*<startdate1>)(?=.*</startdate1> <classcode>)
it didn't work.
so found option.
in 'find' line put:
(?=.*(<startdate)(>))(?=.*(</startdate)(> <classcode>))
and in 'replace' line:
$1 1 $2 $3 1 $4
but result was:
. . </group1> <group2> <id>456</id> <startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate 1 > </startdate 1 > <classcode><startdate>2015-11-02</startdate> <classcode>123</classcode>
so target tags didn't change new added...
and have result:
<group1> <id>123</id> <startdate>2011-11-11</startdate> <city>new york</city> . . </group1> <group2> <id>456</id> <startdate1>2013-10-01</startdate1> <classcode>123</classcode> . . </group2>
is there way not replace tags names manualy?
something this?
<startdate>([\d-]+)<\/startdate>(?=\s*<classcode>)
replace with:
<startdate1>$1</startdate1>
test here
Comments
Post a Comment