问题
I've tried numerous formulas and cannot seem to figure it out using the RIGHT, LEFT and MID functions. Using MS Excel, I would like to extract only one word (two spaces) to the right of my delimiter value ^
.
EXAMPLE: Cell A2
Johnny and I were planning on going to the movie to see ^Batman Returns, but it was to late.
Results: Cell B2
^Batman Returns,
回答1:
Expand the spaces with the SUBSTITUTE and REPT functions then chop out a piece with MID and finally clean it up with the TRIM function.
=TRIM(MID(SUBSTITUTE(A2, " ", REPT(" ", 99)), FIND("^", SUBSTITUTE(A2, " ", REPT(" ", 99))), 199))
回答2:
Here you go:
=MID(A2,FIND("^",A2),FIND("¦",SUBSTITUTE(MID(A2,FIND("^",A2),99)," ","¦",2)))
Just change the '2' at the end to adjust your capture of spaces to the right of the delimiter.
回答3:
Using your example, the following formula it works:
MID(A1;FIND("^";A1);FIND(" ";A1;FIND(" ";A1;FIND("^";A1))+1)-FIND("^";A1))
A1 is the cell where you have your text that will be checked to extract the piece you are interested.
The formula looks for the index of ^ character
FIND("^";A1)
then look for the index of the second space from that ^ character index
FIND(" ";A1;FIND(" ";A1;FIND("^";A1))+1)
use this second index to subtract the first index to get the piece of text length from ^ character until the second space after that
second index first index
FIND(" ";A1;FIND("^";A1))+1) - FIND("^";A1)
AND finally use the MID formula to retrieve the piece of text desirable.
来源:https://stackoverflow.com/questions/32663799/extract-text-one-word-to-the-right-of-delimited-value-within-string