Andreas Hermle

asked on

# extract a substring between backslashes from paths

Dear Experts:

I would like to extract the 'PM_xx' substrings, i.e.

The links have one thing in common.

Looking from the right: these are the substrings between the first and second backslash.

C:\Users\DMD\12-59-11_REV_1-2_RD_2015-07_6s_A4_S220.pdf

C:\Users\8-73-11_REV_7_RD_2015-07_6s_A4_S17.pdf

C:\Users\DMD\Files\REV_2_RD_2015-07_6s_A4_S9.pdf

Help is much appreciated. Thank you very much in advance.

I have attached a sample file for your convenience.

Regards, Andreas

extract_substring.xlsx

I would like to extract the 'PM_xx' substrings, i.e.

**PM_4**,**PM_6**and**PM_2_3**from the below Paths, using a formula if possibleThe links have one thing in common.

Looking from the right: these are the substrings between the first and second backslash.

C:\Users\DMD\

**PM_4**\IFU_marSeal_5_steril_90-0C:\Users\

**PM_6**\IFU_maxium_5_steril_90-04

C:\Users\DMD\Files\

**PM_2_3**\IFU_pincers_90-073-59-14_

Help is much appreciated. Thank you very much in advance.

I have attached a sample file for your convenience.

Regards, Andreas

extract_substring.xlsx

ASKER CERTIFIED SOLUTION

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.

ASKER

Oh great Rgonzo, how quick you came up with this and it works just fine. Thank you very much for it.

If you do not mind, I will wait some more time, maybe some expert or you also come up with a formula approach.

Anyhow, a real superb job from your side. I really appreciate it. Regards, andreas

If you do not mind, I will wait some more time, maybe some expert or you also come up with a formula approach.

Anyhow, a real superb job from your side. I really appreciate it. Regards, andreas

ASKER

uppps, here we are, our posts crossed, will test it right away ... :-)

Edited (a bit more precise)

=MID(A2,FIND("\PM_",A2)+1,FIND("\",A2,FIND("\PM_",A2)+1)-FIND("\PM_",A2)-1)

=MID(A2,FIND("\PM_",A2)+1,

You may also try this....

Assuming your string is in A2 then

Assuming your string is in A2 then

`=TRIM(MID(SUBSTITUTE(A2,"\",REPT(" ",LEN(A2))),LEN(A2)*3,LEN(A2)))`

ASKER

Hi Rgonzo, I am really deeply impressed, how come you come up so fast with all these solutions. It is really incredible, I just do not get it :-)

A great job from your side, as always. Thank you very much for your professional help. I really appreciate it.

Regards, Andreas

A great job from your side, as always. Thank you very much for your professional help. I really appreciate it.

Regards, Andreas

@Neeraj the PM Folder is not allways at the same level

ASKER

Upps, Subodh's and Rgonzo's post have crossed my post. I have already awarded the points. Subodh: will test your code and then let you know. Thank you very much for your great help.

Andreas

Andreas

It's okay Andreas. :)

pls try this UDF

Open in new window

Regardsextract_substringV1.xlsm