Answer:
This article shows how to use regex to remove spaces in between a String.
A string with spaces in between.
String text = "Hello World Java.";
We want to remove the spaces and display it as below:
Hello World Java.
1. Java regex remove spaces
In Java, we can use regex \\s+ to match whitespace characters, and replaceAll("\\s+", " ") to replace them with a single space.
Regex explanation.
`\\s` # Matches whitespace characters.
+ # One or more
StringRemoveSpaces.java
package com.mkyong.regex.string;
public class StringRemoveSpaces {
public static void main(String[] args) {
String text = "Hello World Java.";
String result = text.replaceAll("\\s+", " ");
System.out.println(result);
}
}
Output
Terminal
Hello World Java.
There have only been 3 Little Mermaid movies.
<span>1. The Little Mermaid (1989) </span>
<span>2. The Little Mermaid 2 Return to the Sea (2000) </span>
<span>3. The Little Mermaid 3 Ariel's Beginning (2008)
hope this helps you(:
if not plz let me know (:
have a good day
-denis</span>
Answer:
Sorry mate I tried but I got it wrong!
Explanation:
Sorry again
Answer:
Its C
Explanation:
The largest value that is less then the lookup value