extract " " space from middle of a string

  • Thread starter Thread starter Rasoul Khoshravan
  • Start date Start date
R

Rasoul Khoshravan

a1= bob 1001
there is 10 space between bob and 1001.
I want to extract bob and 1001.
find " " command retuerns the position of last " ", in this case 13. How can
I extract only "bob".
 
thanks for reply.
I used the command you mentioned (FIND(" ",A1)) but it returns 13.
 
=LEFT(A5,SEARCH(" ",TRIM(A5))-1) returns "Bob"
=MID(TRIM(A5),SEARCH(" ",TRIM(A5))+1,256) returns "1001"

Regards,
Stefi


„Rasoul Khoshravan†ezt írta:
 
Hi

I wonder whether you have the non-breaking space CHAR(160) within your
string?
Try =FIND(CHAR(160),A1) and see what that produces.

If it produces a result of 4, then that is where the problem lies.
Try
=LEFT(A1,FIND(" ",SUBSTITUTE(A1,CHAR(160),""))-1)
 
a1= bob 1001
there is 10 space between bob and 1001.
I want to extract bob and 1001.
find " " command retuerns the position of last " ", in this case 13. How can
I extract only "bob".

You could download and install Longre's free morefunc.xll add-in from:
http://xcell05.free.fr/

and then use the formula:

=REGEX.MID(A1,"\w+") to extract the first word
=REGEX.MID(A1,"\w+",2) to extract the second

It should not matter what kind of spaces are between the two "words".


--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top