Extract A String Between Two Characters

theaudioguy

New Member
Joined
Jan 27, 2010
Messages
27
I'm stuck. I need a formula to extract data from between two characters.

For Example, In A1 I have this: COMP_PROG_v1_ABCD_01

I want to extract the value between the 3rd and 4th "_"'s. The number of "_"'s will be consistent but not the # of characters between them. My brain is tired of thinking. Thanks.
 
Hello,

can you help with getting this result? Tried to make formula, but I am not sure if I did it the way it should be done.

Thank you

Sheet1

AB
1InputResult
22017-04-20 19:49:10,530 [Thread-835958] DEBUG B_W213St150_v01.js - callback: Value: [[2032]], Timestamp: Št apr 20 19:49:10 CEST 2017, Quality: 192, ErrorCode: 00000000[Thread-835958]
32017-04-20 19:49:40,763 [Thread-836075] DEBUG B_W213St150_v01.js - callback: Value: [[2027]], Timestamp: Št apr 20 19:49:40 CEST 2017, Quality: 192, ErrorCode: 00000000[Thread-836075]

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:1082px;"><col style="width:113px;"></colgroup><tbody>
</tbody>

Formeln der Tabelle
ZelleFormel
B2=TRIM(LEFT(SUBSTITUTE(MID($A2;FIND(" ";SUBSTITUTE($A2;" ";" ";COLUMNS($B:B)))+14;LEN($A2));" ";REPT(" ";LEN($A2)));LEN($A2)))
B3=TRIM(LEFT(SUBSTITUTE(MID($A3;FIND(" ";SUBSTITUTE($A3;" ";" ";COLUMNS($B:B)))+14;LEN($A3));" ";REPT(" ";LEN($A3)));LEN($A3)))

<tbody>
</tbody>

<tbody>
</tbody>


Excel Tabellen im Web darstellen >> Excel Jeanie HTML 4.8
 
Last edited:
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Thanks Martvg,

this is definitely better formula. One more question, what if I want to extract just third field, after the second space (let's say expression [Thread is replaced by something else...)?
 
Upvote 0
I'm not sure if I understand your question, do you want to retrieve the value between the second and third space no matter what the value is?
In that case, this should do the trick:

=SUBSTITUTE(MID(SUBSTITUTE(A4," ",REPT(" ",100)),175,100)," ","")

Best regards,
 
Last edited:
Upvote 0
With
A1: COMP_PROG_v1_ABCD_01

This formula returns the characters between the 3rd and 4th underscores (_):
Code:
B1: =TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("|",SUBSTITUTE(A1,"_","|",3))+1,
LEN(A1)),"_",REPT(" ",LEN(A1))),LEN(A1)))
In the above example, the formula returns: ABCD

Does that help?


@Ron et. al, I've tried searching the net to no avail:
  1. What is the vertical bar (" | ") used for in your formula (i.e., in your formula, there are no other vertical bars but it still works somehow)?
  2. What other applications can this symbol be used for?
 
Upvote 0
Apologies for the delayed response. (For some reason, my company keeps blocking this website)
I'll incrementally decompose that formula...See if this helps:
Code:
=TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("|",SUBSTITUTE(A1,"_","|",3))+1,
LEN(A1)),"_",REPT(" ",LEN(A1))),LEN(A1)))
=TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("|","COMP_PROG_v1|ABCD_01")+1,
20),"_",REPT(" ",20)),20))
=TRIM(LEFT(SUBSTITUTE(MID(A1,13+1,
20),"_",REPT(" ",20)),20))"
=TRIM(LEFT(SUBSTITUTE("ABCD_01","_",REPT(" ",20)),20))
=TRIM(LEFT(SUBSTITUTE("ABCD_01","_","                    "),20))
=TRIM(LEFT("ABCD                    01",20))
=TRIM("ABCD                ")
="ABCD"
 
Upvote 0
Try this
Code:
[B]=TRIM(MID(SUBSTITUTE(A1,"_",REPT(" ",99)),99*3,99))[/B]

Book1
AB
1COMP_PROG_v1_ABCD_01ABCD
Sheet1
 
Upvote 0
I need some help with a formula that will provide the xx.xxOZ from text strings such as these:
PRIVATE LABEL BRAND SALTED ROASTED REGULAR 40OZ 126980474

<colgroup><col width="482" style="width:362pt"> </colgroup><tbody>
</tbody>
HAPPY SALTED ROASTED REGULAR 6.25OZ 1344702821

<colgroup><col width="482" style="width:362pt"> </colgroup><tbody>
</tbody>
YOYO FARMS SALTED ROASTED HEDGEHOGS 16OZ 4581328954

<colgroup><col width="482" style="width:362pt"> </colgroup><tbody>
</tbody>


Thanks for the help
 
Upvote 0
If your examples are truly representative, it appears that the OZ's text is always the next to the last item in the text. If that is true, then this formula will return it...

=TRIM(LEFT(RIGHT(SUBSTITUTE(A1," ",REPT(" ",200)),400),200))
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,381
Members
449,155
Latest member
ravioli44

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