I have string which should be split on "." (point) and " " (space). I have tried:
s.split("[\\s\\.]")
but it doesn’t work, because it hasn’t split this string normally – "123 456 . 11323 1".
How should I change my regular expression?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will get a lot of blank spaces if you only split on a single character.
will produce “123”, “456”, “11323”, “1”.
The
+causes it to treat any run of spaces and dots as a single break instead of returning a string between adjacent spaces and dots.You might still get blank strings at either end of your results since given
" 123"it will split between the start of the string and “123”.