0
votes

Hi! sorry for my bad english.
I need to remove the space before the capital letter and replace it with {b} via Regex.
Example
Before
Brand-Makel Code-123456
After
Brand-Makel{b}Code-123456
Help me please.

1
With which regex have you come up so far and why does it not work? Replacing [ ]([A-Z]) with {b}\1 seems like a trivial solutionknittl

1 Answers

0
votes

You can do that using a lookahead, it is used to ensure that a specific text follows the match:

\s(?=[A-Z])

All spaces followed by a capital letter will be matched.

  • \s: matches any whitespace character.
  • (?=): positive lookahead.
  • [A-Z]: matches a single character in the range between A and Z.

You can test it here.