• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to split a string between commas, one or more spaces and between digits and letters but not between dots with regex in java?

Resolved: How to split a string between commas, one or more spaces and between digits and letters but not between dots with regex in java?

0
By Isaac Tonny on 01/04/2023 Issue
Share
Facebook Twitter LinkedIn

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
I want to have an Array like this:
I have the following:
But this also splits the the date between digits and dots. How can I prevent to split between the digits and dots?

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.,])
Output:
Demo at regex101

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

java regex split
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to stop a thread that has a blocking function from easygui in python

05/04/2023

Resolved: Removing null keys from a json array of objects

05/04/2023

Resolved: How can I generate at compile-time a separate OpenAPI Swagger.json file for each Controller in my ASP.NET project?

05/04/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.