PHP正则表达式删除特定字符串中的空格

Im trying to remove the " " (space) in the following string. Be aware that this is only part of a string (there are valid spaces in it just not this one). So the code should identify this string then remove the space.

Example:

18-Sep 00:20

Test:

/\d{1,2}-[a-z]{3}\s*( )\d{2}:\d{2}/

Or try

/(\d{1,2}-[A-Z][a-z]{2}) +(\d{2}:\d{2})/   // REGEXP

with

"$1$2"         // as the replacement string

This way the replacement will only affect string fragments with three digit month names, starting with a capital letter. It will also remove more than one blanks if necessary.

You might use lookarounds:

(?<=\w) (?=\d{2}:\d{2})

See a demo on regex101.com.


Broken apart, this says:
(?<=\w)         # pos. lookbehind
\               # space
(?=\d{2}:\d{2}) # 00:11 format