stuff Th...">

Regular expression to replace xml attribute

I have an xml form file:

<property name="foo" value="this is a long value">stuff</property>

There are many properties, but I want to combine the name with the name foo, and then replace its value attribute with something else:

<property name="foo" value="yet another long value">stuff</property>

I was thinking of writing a regex to match everything after "foo" to the end of the tag (">") and replace it, but I cannot get the syntax correctly.

I am trying to do this with sed if that helps.

+3
source share
2 answers

/property name=\"foo\" value=\"([^\"]*)\"/

Then simply replace the first profile with the new value of the desired one.

+7
source

, XML . xslt, xml .

+5

Source: https://habr.com/ru/post/1706942/


All Articles