I have a string like :
Article 1404565001 für Unterputz-, Spülkasten Nr. 240.705
or
string : Aufputz Spülkasten AP140 für 2-Mengen-Spülung, Toilettenspülung tief hängend, mit flexiblem Wasseranschluss, geräuscharm, weiß, Art.Nr. 140300111
I need just 1404565001 or 140300111
So need to get first numeric with a length > 5 digit
This is a solution ,thank you . But now i realise that some numbers are like 234.343.3.42 and this kind of number are not included in this regex. How can i fix to remove dots and to include this numbers too ?
I’m struggling to think how to do the count portion when there are an unknown number of . characters that could be found in between the digits. @Steven_McKeering perhaps you have an idea?
I do know that once you get your string returned that could include the .character, you can just do a simple .replace() to fix it. This works even if there were no . in the returned string. So if MyString = 234.5.3.2 or MyString = 234532 both would return 234532 when you do MyString = MyString.Replace(“.”,string.empty)
Not sure why I didn’t think of this previously, but you can flip the order and do the string.replace first, then do your regex
So step 1 = assign MyString = Mystring.Replace(“.”,string.empty)
step 2 = use the regex I posted previously
Note that if you need to use MyString as-is for reasons other than this, then you should create a new string in step 1 rather than changing the existing string
System.Text.RegularExpressions.Regex.Match(Tit,“[0-9]+(.[0-9]{1,10})?(.[0-9]{1,10})?(.[0-9]{1,10})”).Value i used this expresion and seems is working . Thank you for your help
I would highly recommend my latest commented solution instead as it’s a bit easier to read and understand (I can’t follow how the count portion is working in your latest regex). But as long as it is working then no worries
EDIT: The solution you posted seems to be capturing the numbers even if it is less than 5 digits, and it also captures patterns such as 2.3.65 even though that’s only 4 digits long