Hi there,
I need help because my solutions aren't working - at least not always.
I have a vba function called "extract(s as string) as string", which is supposed to find a 10-digit number starting with "45", "46" or "90" anywhere within a string, and return it if found, otherwise return empty string.
I'm finding that if 45, 46 or 90 appear elsewhere in the string, then it will also return that, and miss the 10-digit number - which causes problems.
Whats the best way to return the 10-digit number in the below string cases?
"Hello this is my number 4534567890"
"4534567890 is my number"
"the number 45 appears in 4534567890"
"the number 4534567890 includes the digits 45 at the start"
"the number 4534567890 also includes 90 at the end"
"there are sometimes no spaces in front of4534567890"
"sometimes 4534567890 comes before 4509876543" -in which case I need only the first instance - or an array of matches, but that's maybe getting ahead of ourselves.
"there's no match in 900046045 as it's not 10 digits long"
Is there a regex statement that I could use (and if so, how)? Not just to detect the presence of a matching number, but to actually return it.
many thanks
Guy
Bookmarks