You can use this lookaround based regex:
String repl = "Hello 111 222 333 World!".replaceAll("(?<=\\d) +(?=\\d)", "");
//=> Hello 111222333 World!
This regex "(?<=\\d) +(?=\\d)"
makes sure to match space that are preceded and followed by a digit.
More Related Contents:
- Regular Expression for name
- How to get a substring through regex in java android?
- Java doesn’t work with regex \s, says: invalid escape sequence
- Regex date validation for yyyy-mm-dd [duplicate]
- Unfortunately MyApp has stopped. How can I solve this?
- Regex for splitting a string using space when not surrounded by single or double quotes
- Cannot create or edit Android Virtual Devices (AVD) from Eclipse, ADT 22.6
- java regular expression to extract content within square brackets
- Change background color of single specific menu items of navigationView
- Create a new TextView programmatically then display it below another TextView
- Why does my function that calls an API or launches a coroutine return an empty or null value?
- I would like to set my variables at the top of my class instead of in the method
- What exactly does URLConnection.setDoOutput() affect?
- Java: Split string when an uppercase letter is found
- RecyclerView not calling onCreateViewHolder or onBindView
- What is the correct way to do inserts/updates/deletes in Android SQLiteDatabase using a query string?
- Android Days between two dates
- java.lang.RuntimeException: takePicture failed
- Regex that Will Match a Java Method Declaration
- How to print to the console in Android Studio?
- Google Maps API and custom polyline route between Markers
- Set minimum and maximum characters in a regular expression
- Cant start service? (Speech recog)
- android studio with Java compiler error: string too large to encode using UTF-8 written instead as ‘STRING_TOO_LARGE’
- What is the maximum amount of data that a String can hold in java? [duplicate]
- android: changing option menu items programmatically
- How to get the Context from anywhere? [duplicate]
- Can’t Disable Offline Data In Firestore
- Firestore query order on field with filter on a different field
- VoIP RTP Streaming from/to server (in Java) to/from android