Core Java Interview Topics
Tuesday, February 5, 2019
Java string.split - by multiple character delimiter?
String.split
takes a regular expression, in this case, you want non-word characters (regex
\W
) to be the split, so it's simply:
String
input
=
"Hi,X How-how are:any you?"
;
String
[]
parts
=
input
.
split
(
"[\\W]"
);
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment