I want to change this string "D:\Adapte​rs\04_easy​\00_CodeGe​n\algo\gen​\cdp" to get "D:\Adapters\04_easy\". Which function should I use? Regexprep doesn't seem to work.

1 view (last 30 days)
srcpath="D:\Adapters\04_easy\00_CodeGen\algo\gen\cdp";
I want
newsrcpath="D:\Adapters\04_easy\";

Accepted Answer

Walter Roberson
Walter Roberson on 2 Dec 2015
pos = find(srcpath == '\', 3, 'first');
newsrcpath = srcpath(1:pos(3))

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!