Penikton Bernard

Penikton Bernard

  • NA
  • 43
  • 21.4k

How to convert Wildcard pattern into regex pattern using C#

Jun 10 2014 6:06 AM

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)