Replacing brackets in java using Regular Expression.
public static void main (String args[]){
String pattern = "throw new Exception\\("; // pattern
String b = "throw new Exception("; //Match Against
String c = "throw new CustomException(;"; //Replace By
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(b);
String d = m.replaceAll(c);
System.out.println(d);
boolean bo = m.matches();
System.out.println(bo);
}
Friday, June 13, 2008
Using Regex in java
at 7:42 AM
Labels: Java, regex, Replacing brackets using regular expressions
Subscribe to:
Post Comments (Atom)
1 comment:
Hi this help me very lots abt how to implemmt the real time application in java...
Post a Comment