Extracting certain text from string

Son

Active Member
Joined
Mar 19, 2010
Messages
284
hi, i have a series of text with some numbers in it and i'd like to extract these numbers, not the letters.

here's an example:

I WENT TO - PARIS - (NOT ALONE) AND MY NUMBER WAS 2.6.3 AND I HAD A LOF OF FUN

I WENT TO - PRAGUE - (ALONE) - AND I DID NOT HAVE A NUMBER BUT I HAD 2.13.4 AND I HAD A LOT OF FUN WITH MR. FUNNY

I WENT TO MILAN - (NB. I WAS NOT ALONE) - AND I HAD FUN - 8.15.14.1 AND I DID NOT HAVE A LOT OF FUN WITH MR. NOT FUNNY

What is known:
each case of numbers has 3 . maximum
the first number is always one digit
the rest of the numbers can be with two digits
there can be . either before or after the series of numbers
everything is regarded as text
the . do not correspond to decimals, they are just text
the desired outcome is: 2.6.3 and 2.13.4 and 8.15.14.1 for the above examples

any ideas on this would be most appreciated!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
each case of numbers has 3 . maximum
the desired outcome is: 2.6.3 and 2.13.4 and 8.15.14.1 for the above examples

Isn't there 4 cases of numbers for 8.15.14.1?
 
Upvote 0
assuming thats the only numbers in the text string
=trim(mid(substitute(a1," ",rept(" ",25)),find(mid(a1,min(find({0,1,2,3,4,5,6,7,8,9},a1&"0123456789")),1),substitute(a1," ",rept(" ",25))),15))
 
Upvote 0
=trim(left(substitute(replace(a1,1,min(find({0,1,2,3,4,5,6,7,8,9},a1&"0123456789"))-1,"")," ",rept(" ",255)),255))
 
Last edited:
Upvote 0
=trim(left(substitute(replace(a1,1,min(find({0,1,2,3,4,5,6,7,8,9},a1&"0123456789"))-1,"")," ",rept(" ",255)),255))

That is cool. Hotpepper - could you please break that down for me? I'm new to this so I'd like to learn.
 
Upvote 0
Martin, you're a genius! It works perfectly!!!

i have to study the formula, of course, to find out how it works, but it does work!!! Thank you!!!

and kpark, yes, i know, i see now that i put one extra . in my example.

thanks both for your immediate response!

i have to say, excel never ceases to amaze me!
 
Upvote 0
also, Hotpepper, your formula works too! i notice it is simpler than martin's, still both work. i will need to break each down to find out how they actually do it, but for now, my task is complete! thank you both
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,448
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top