Home » Javascript » Pattern to List of Patterns

Pattern to List of Patterns

Posted by: admin August 19, 2018 Leave a comment


I actually have this case where I have to verify if there’s an overlapping pattern (may it be regex or something else).

string pattern = "123*"
string[] patterns = new string[]  { "123?", "123*", "12?", "*23*" }

I believe from here the overlapping matches are "123?", "123*" and "*23*"

Wild cards would be limited to "*" for any trailing characters and/or "?" for any 1 length

This by the way is for the purpose on number formats so there’s a possibility also to include literal dashes (at most) within number patterns / formats.

Can this be accomplished with Regex or other? in C# / Javascript if possible.

Please put a comment for any info I missed.