Solved Compare two alphanumeric Strings

August 31, 2014 at 23:44:49
Specs: Windows 7
I have two strings , (One is string format and other one is output from a code)

eg:- string format = "Revision-NNNN,Date-AAA-NN-NN"
// N - Indicates Numeric digit and A indicates Alphanumeric character

string output = "Revision-0205,Date-Sep-01-14"

Both the strings are same in terms of format.
For eg if output string is "Revision-0A0B,Date-Sep-0A-14" then the output string is not matching with the format. (As 0A0B is not numeric as mentioned in String Format)

Is there any way to match the above strings using REGEX in C#?

See More: Compare two alphanumeric Strings

Report •

September 2, 2014 at 09:26:25
✔ Best Answer
Sure. It'd take a little work, but you could do it.

Call Regex.Escape() on the format string, then take the resulting string and replace "N" with "[0-9]", and "A" with "[a-z,A-Z,0-9]". You can use that string as the pattern to match.

How To Ask Questions The Smart Way

Report •
Related Solutions

Ask Question