java - Adding a markup outside an existing tag regex -


i have xml alone, wanted add markup outside of tag called scl

so example

<documents> <rnl></rnl> <snl></snl> <scl>this scl</scl> </documents> 

so <scl>this scl</scl> transformed <credit><scl>this scl</scl></credit> how modify below achieve ? far have tried.

string content5 = "<scl>this scl</scl>"; system.out.println(content5.replaceall("^(?:&lt;scl&gt;)(?:.*?)(?:&lt;/scl&gt;)", "<credit>$1</credit>" )); 

here go:

string content5 =      "<scl>this scl</scl>\n" +     "<blah>this isn't</blah>\n" +     "<scl>this scl</scl>\n" +     "<blah>this isn't</blah>\n"; system.out.println(content5.replaceall("(?:<scl>)(?:.*?)(?:</scl>)", "<credit>$0</credit>" )); 

output:

<credit><scl>this scl</scl></credit> <blah>this isn't</blah> <credit><scl>this scl</scl></credit> <blah>this isn't</blah> 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -