I have a bunch of lines from which I need to extract numbers. They are in the format:
XXXX001 XXXXXXX004 XX0234X
There are many of them, and I need to sort through them all and extract all the numbers.
So, what is the fastest / most efficient way, using ASP.NET 3.5, to find the first instance of a number inside a string?
Update I should have included more information - getting answers giving me ideas on how to extract all numbers and not find the first index. Not a problem - I'm sure others will find them useful.
In my case, I really need an index, because I'm doing a bit more string analysis (i.e. there might be a range XXXX0234-0237XX or a couple XXXXX0234 & 0238XX.
Finding the index of the first number helps me orient the interesting part of the string to check.
source share