w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Java :How to replace any space (not whitespace), just space, which is not followed by another space with no space

You can use the following expression:

// ^
// There is a space here

This will match any space character as long as it is followed by something which is not a space S.

Or if you prefer just regular spaces then:

(?! )

In Java:

String input = "4054a4:e8 c8 f0 ff ff   callq  404571
String result = input.replace(" (?! )", "");

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.