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.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Give this formula a try...

=LOOKUP(9E+99,--LEFT(MID(A2,SEARCH("kvp__value qa-pd-weight"">",A2)+25,99),ROW(INDEX(A:A,1):INDEX(A:A,16))))
 
Upvote 0
Hello,

I have read through the entire thread but don't think I've seen anything that covered this problem:

I need the strings between the second "=" and before the second "&"


<tbody>
[TD="align: left"]http://web1.parts-cat.com/default.aspx?14=1&32=16637&1230=9997&10=6A47A456188C420187D8EE6E3303296E018001&12=110[/TD]

[TD="align: left"]http://web1.parts-cat.com/default.aspx?14=1&32=193&1230=9997&10=6A47A456188C420187D8EE6E3303296E018001&12=110[/TD]

[TD="align: left"]http://web1.parts-cat.com/default.aspx?14=1&32=3119&1230=9997&10=6A47A456188C420187D8EE6E3303296E018001&12=110[/TD]

</tbody>

16637
193
3119
(length of this string - actually always figures if that makes it easier - can be from 1 to 6)

A normal text search would not work, as the text before and after the special characters can vary.
Thanks a lot for help
Andreas
 
Upvote 0
Pityuse, try this:

With A1 containing the initial string.

=LEFT(RIGHT(SUBSTITUTE(SUBSTITUTE(A1,"=","~",2),"&","~",2),LEN(A1)-FIND("~",SUBSTITUTE(SUBSTITUTE(A1,"=","~",2),"&","~",2))),FIND("~",RIGHT(SUBSTITUTE(SUBSTITUTE(A1,"=","~",2),"&","~",2),LEN(A1)-FIND("~",SUBSTITUTE(SUBSTITUTE(A1,"=","~",2),"&","~",2))))-1)
 
Upvote 0
Rick, I had a feeling that you would post the first reply and it works as it should and I am not one bit surprised it does. THANKS!!
 
Last edited:
Upvote 0
Hello Peter, thanks for your solution as well. You helped me out with a function ("findcommons" -> common numbers across multiple cells with many different numbers within each cell; about 2 years ago) and that has been very useful for me!! In fact, I might ask for some finetuning of that function :) Rick also presented a solution for that problem back then. You even wrote a benchmark program to compare the various solutions! Great community here!
Andreas
 
Upvote 0
Thanks this work ...
if you don't mind how can you get number 9 in that formula ?

You are welcome.

The formula searches for the location of "weight" in the string (in your example 384 characters from the start of the string) and 9 (characters) are added to get to the number you want to extract. Of course, this formula won't work if this "distance" is not 9 characters.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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