Search and find in a string of text

Dojorgen

Board Regular
Joined
Mar 1, 2018
Messages
59
Hey guys hoping you could help me out with this:

String of text:
'CMD/A="RES_ACTIVATE" MID/A="vfei2W0206" MTY/A="C" TID/U4=373 TYPE/A="RECIPE" RES_ID/A="E.299.30" PORT_ID/B=1 MBC_ID1/A="419253901.000" MBC_ID2/A="BLANK"'

Search for:
Line of text looking to pull search for "RECIPE"

If true then results:
then results the "E.299.30"
and next column "419253901.000"
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Excel 2010
ABC
1CMD/A="RES_ACTIVATE" MID/A="vfei2W0206" MTY/A="C" TID/U4=373 TYPE/A="RECIPE" RES_ID/A="E.299.30" PORT_ID/B=1 MBC_ID1/A="419253901.000" MBC_ID2/A="BLANK"E.299.30""419253901.000"
Sheet1
Cell Formulas
RangeFormula
B1=IFERROR(TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("RES_ID/A",A1)+9,255)," ",REPT(" ",255)),255))&T(FIND("RECIPE",A1)),"")
C1=IFERROR(TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("MBC_ID1/A",A1)+10,255)," ",REPT(" ",255)),255))&T(FIND("RECIPE",A1)),"")
 
Last edited:
Upvote 0
sorry should have been more specific instead of "E.299.30" and "419253901.000" just have it so it is E.299.30 and 419253901.000
 
Upvote 0
Hi,

You've Only shown one sample text string without much of a description...
If "RECIPE" is found, will there Always be 2 substrings to extract?
If so, are they Always following RES_ID/A, and MBC_ID1/A?
Will there be a valid value in MBC_ID2/A (or more, i.e. MBC_ID3/A, MBC_ID4/A, etc.) you might want extracted?

Edit: Perhaps you should show a few more samples.
 
Last edited:
Upvote 0
Yes thank you for asking if "RECIPE" is found there will always be 2 sub strings to extract it works perfect i was hoping just get ride of the quotes
 
Upvote 0

Excel 2010
ABC
1CMD/A="RES_ACTIVATE" MID/A="vfei2W0206" MTY/A="C" TID/U4=373 TYPE/A="RECIPE" RES_ID/A="E.299.30" PORT_ID/B=1 MBC_ID1/A="419253901.000" MBC_ID2/A="BLANKE.299.30419253901.000
Sheet1
Cell Formulas
RangeFormula
B1=SUBSTITUTE(IFERROR(TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("RES_ID/A",A1)+9,255)," ",REPT(" ",255)),255))&T(FIND("RECIPE",A1)),""),"""","")
C1=SUBSTITUTE(IFERROR(TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("MBC_ID1/A",A1)+10,255)," ",REPT(" ",255)),255))&T(FIND("RECIPE",A1)),""),"""","")
 
Upvote 0
....i was hoping just get ride of the quotes
You could just SUBSTITUTE them away...

=IFERROR(TRIM(SUBSTITUTE(LEFT(SUBSTITUTE(MID(A1,FIND("RES_ID/A",A1)+9,255)," ",REPT(" ",255)),255),"""",""))&T(FIND("""RECIPE""",A1)),"")

=IFERROR(TRIM(SUBSTITUTE(LEFT(SUBSTITUTE(MID(A1,FIND("MBC_ID1/A",A1)+10,255)," ",REPT(" ",255)),255),"""",""))&T(FIND("RECIPE",A1)),"")
 
Last edited:
Upvote 0
Thanks for all the great responses works great.......there is about 50K lines of text and i did find a "MBC_ID1/A" and a "MBC_ID2/A" if someone would like to help add that to the string that would be great appreciated all the help you guys have always been great

'CMD/A="RES_ACTIVATE" MID/A="vfei2W0206" MTY/A="C" TID/U4=419 TYPE/A="RECIPE" RES_ID/A="E.242.50" PORT_ID/B=2 MBC_ID1/A="BLANK" MBC_ID2/A="419260011.000"'
 
Upvote 0
See again Post # 4.

In the Single sample you gave in OP, and the sample in Post #8 , what happens when the value is "BLANK"?
 
Upvote 0
Looks like two different scenarios, for now using the above search "MBC_ID1/A it either displays 419253901.000 or BLANK. It would only be either or never both so the formula would need to FIND: MBC_ID1/A with criteria IF: "BLANK" FIND: MBC_ID2/A

'CMD/A="RES_ACTIVATE" MID/A="vfei2W0206" MTY/A="C" TID/U4=373 TYPE/A="RECIPE" RES_ID/A="E.299.30" PORT_ID/B=1 MBC_ID1/A="419253901.000" MBC_ID2/A="BLANK"'
'CMD/A="RES_ACTIVATE" MID/A="vfei2W0206" MTY/A="C" TID/U4=419 TYPE/A="RECIPE" RES_ID/A="E.242.50" PORT_ID/B=2 MBC_ID1/A="BLANK" MBC_ID2/A="419260011.000"'


 
Upvote 0

Forum statistics

Threads
1,214,886
Messages
6,122,093
Members
449,064
Latest member
Danger_SF

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