In this post, we will see how to resolve How to split a string between commas, one or more spaces and between digits and letters but not between dots with regex in java?
Question:
As the title says I like to split a String between commas, one or more spaces and between digits and letters but not between dots with regex in java?So for eample if I have the following String
Best Answer:
You can use[^\d.]
instead of \D
to exclude digits and dots.Also I’ve added
\s,
to negation, to exclude double split between space (or comma) and digits: [\s,]+|(?<=[^\d\s.,])(?=\d)|(?<=\d)(?=[^\d\s.,])
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com