java - String Manipulation -
This form is XxYxZx in my string
are X, Y and Z characters and are X numbers Can be different from 0-999.
I want to split this string into this form. How can this be done?
Example: Output: Explanation: < Code> string myString = "A155B45C77D89"; String [] parts = myString.split ("(? & Lt; = \\ d) (? = \\ p {alpha})"); Println (Arrays.toString (parts));
[A155, B45, C77, D89]
String.split works with regular expressions. Regular expression
(? & Lt; = \ d) (? = \ P {alpha}) says, "matches all the substrings moving forward one digit, succeeded by an alphabet character < In the string such as / em>
"A155B45C77D89" , this expression corresponds to empty substrings
A155 B45 C77's D89 ^ ^ ^ here | | here | | and here
Comments
Post a Comment