I'm trying to find a way to extract a word from a string only if it contains 3 or more digits/numbers in that word. It would also need to return the entire text like
TX-23443
orFUX3329442
etc...
From what I found
\w*\d\w*
won't return the any letters before the dash like the first example?
All the example I found online don't seem to be working for me. Any help is appreciated!
IF I understand your question correctly you wanted to find all the string which contains 3+ consequtive numbers in it such as TX-23443 or FUX3329442 so you wanted to extract TX-23443
and FUX3329442
even if it contains -
in between the string. So here is the solution which might help you
string InpStr = "TX-23443 or FUX3329442";
MatchCollection ms = Regex.Matches(InpStr, @"[A-Za-z-]*\d{3,}");
foreach(Match m in ms)
{
Console.WriteLine(m);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With