ask how to achieve better and faster replacement !
------ Solution ------------------------------------ --------
public class tihuan {
public static void main(String[] args){
String s="<string name=\"STR_ABC\">ABC</string>";
System.out.println(s.replaceAll("(<.*>)ABC(<.*>)","$1hello$2" ));
}
}
------ Solution ------------------------------------ --------
way too much
String s = "<string name=\"STR_ABC\">ABC</string>";
System.out.println(s.replace(">ABC<", ">hello<"));
------ Solution ------------------------------------- -------
nothing encore
public class tihuan {
public static void main(String[] args) {
String s = "<string name=\"STR_ABC\">ABC</string>";
System.out.println(s.replaceAll("(?<=>)\\w+(?=<)", "hello"));
}
}
------ For reference only ----------------------------------- ----
essence is a regular problem !
is my piece of the regular expression is too weak !
------ For reference only -------------------------------------- -
essence is a regular problem !
is my piece of the regular expression is too weak !
this hard to understand ...
------ For reference only --------------------------- ------------
this is easy to understand , perform discovery performance is also good
------ For reference only ---------- -----------------------------
2L that okay ? I just tested on the JSP , the result str output is ABC. Pit father .
------ For reference only -------------------------------------- -
String str = "
str.replaceAll ("> ABC <", "> hello <");
%>
Str: <% = str%>
Here is the web interface , do not know what the problem is in addition to , how will output the ABC.
没有评论:
发表评论