I am attempting to use regular expression to replace all occurrences of UK car registrations within a string.
The following swift code works perfectly for a when the
With pattern: "^ ... $" you have specified that the pattern is anchored to the start and end of the string, in other words, the entire string must match the pattern. Just remove ^ and $ from the pattern and you'll get the expected result.
pattern: "^ ... $"
^
$