Java string split with "." (dot)
To split a string in Java using a dot (.
) as the delimiter, you can use the split
method of the String
class.
Here is an example of how to do this:
String input = "this.is.a.test";
String[] parts = input.split("\\.");
This will split the input string into an array of strings, using the dot as the delimiter. The resulting array will be: {"this", "is", "a", "test"}
.
Note that you need to use a double backslash (\\
) to escape the dot, as the dot has special meaning in a regular expression.
I hope this helps! Let me know if you have any questions.