12
Answers

How to convert Wildcard pattern into regex pattern using C#

Photo of Penikton Bernard

Penikton Bernard

11y
5.5k
1

For eg:

I have wildcard pattern to find UK format dates

Wildcard pattern : [0-9]{1,2}[dhnrst]{2} <[AFJMNSOD]*> [0-9]{4} // this pattern will find the UK format date "7th August 2001"

Out put also will find the UK format dates, but out put should be in regex format as follows.

\b[0-9]{1,2}[th|rd]+\s[\w]+\s[0-9]{4}\b // this regex pattern also will find the UK date format "7th August 2001"

Please suggest me how to bring this output using c#. (Except string find and replacement method)

Answers (12)