Regex to pull out only integers from a string and ignore floats and fractions
Regex OnlyIntegers = new Regex(@"(?<![\.]|[0-9]/)\b[0-9]+(?![\./][0-9]+)(?=[a-zA-Z]*\b)"); string InputText = "the 12mp 2. 00.200 00300 .4500 float values /34 1-1/2 22 33/55 or 3/2 are in the range of 55 mm .555 or 0.550,0.5,-3.000 and the values are 10.44,24.553,1.023, 5.67,2.34";
Output:
12
2
00300
34
1
22
55
Comments
Post a Comment