How to extract string from another string

gilsa

New Member
Joined
Sep 16, 2014
Messages
21
Hi All,
I'd highly appreciate to get some help on how to extract from a dynamic string length each time another part of it.
For instance the string might be:
1. \Sky\6.1.1
2. \Sky\6.1.1\6.1.10
3. \Sky\6.1.1\6.1.10\Sprint 1

If at the end the "Sprint 1" part exists then I need to fetch only 6.1.10
If not, the string from the right side until the "\" character (i.e either 6.1.1 in example 1 or 6.1.10 in example 2).

Many thanks in advance,
Gil
 
At this point it is most likely that after the number, if exists, the part will start with or contain the word sprint.
What I hardly believe might be changed at any certain point is the "\", which separates between the string parts.
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If you want to delete any substrings starting with Sprint after the last backslash, use this formula:

=TRIM(RIGHT(SUBSTITUTE(REPLACE(A1,FIND("\Sprint",A1&"\Sprint"),99,""),"\",REPT(" ",99)),99))

Similar result can be achieved without a formula, if you press Ctrl-H and replace „\Sprint*” with nothing (without quotation marks) then „*\” with nothing (if you want to keep the original, make a copy before replacing).

The formula below is more general, it deletes the last „\” with the following substring if the word „Sprint” appears anywhere in the cell:

=TRIM(LEFT(RIGHT(SUBSTITUTE(A1,"\",REPT(" ",99)),(1+COUNTIF(A1,"*Sprint*"))*99),99))
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,591
Members
449,089
Latest member
Motoracer88

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