Skip to content

Instantly share code, notes, and snippets.

@yauhen-info
Created February 13, 2014 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yauhen-info/8974545 to your computer and use it in GitHub Desktop.
Save yauhen-info/8974545 to your computer and use it in GitHub Desktop.
Change boundaries of found pattern
package info.yauhen;
public class BoundariesEditor {
public static void main(String[] args) {
//Substitute
String testString = "<Test> <LCOc1>";
testString = testString.replaceAll("\\(", "<").replaceAll("//", ">");
testString = testString
.replaceAll("<[A-Za-z0-9\\.\\-=]+>", "($0)")
.replaceAll(">\\)","\\)")
.replaceAll("\\(<","\\(");
System.out.println(testString);
}
}
@yauhen-info
Copy link
Author

Input:
<Test> <LCOc1>

Output:
(Test) (LCOc1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment