2021年3月19日星期五

Match part of a string with regex

I have two arrays of strings and I want to check if a string of array a matches a string from array b. Those strings are phone numbers that might come in different formats. For example:

Array a might have a phone number with prefix like so +44123123123 or 0044123123123

Array b have a standard format without prefixes like so 123123123

So I'm looking for a regex that can match a part of a string like +44123123123 with 123123123

Btw I'm using Swift but I don't think there's a native way to do it (at least a more straightforward solution)

EDIT

I decided to reactivate the question after experimenting with the library @Larme mentioned because of inconsistent results.

I'd prefer a simper solution as I've stated earlier.

https://stackoverflow.com/questions/66680489/match-part-of-a-string-with-regex March 18, 2021 at 04:06AM

没有评论:

发表评论