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("^(?:<scl>)(?:.*?)(?:</scl>)", "<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
Post a Comment