Removing whitespace between consecutive numbers

Removing whitespace between consecutive numbers

I have a string, from which I want to remove the whitespaces&nbsp;<em>between the numbers</em>:

I have a string, from which I want to remove the whitespaces between the numbers:

string test = "Some Words 1 2 3 4";
string result = Regex.Replace(test, @"(\d)\s(\d)", @"$1$2");

the expected/desired result would be:

"Some Words 1234"

but I retrieve the following:

"Some Words 12 34"

What am I doing wrong here?

Further examples:

Input:  "Some Words That Should not be replaced 12 9 123 4 12"
Output: "Some Words That Should not be replaced 129123412"

Input: "test 9 8" Output: "test 98"

Input: "t e s t 9 8" Output: "t e s t 98"

Input: "Another 12 000" Output: "Another 12000"


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

C/C++ vs. Rust: A developer’s perspective

In this post, you'll see the difference between Rust and C/C++ in a developer’s perspective

C# Regex Alpahnumeric String

I'd like to check whether a string contains the following Groups. All Strings MUST contain exactly 2&nbsp;<em>##</em>