Swift replace substring regex

前端 未结 6 1528
执念已碎
执念已碎 2020-11-29 04:53

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

6条回答
  •  心在旅途
    2020-11-29 05:53

    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.

提交回复
热议问题