Getting parts of string with for loop
조회 수: 2(최근 30일)
Hi hopefully u can help me!
I have the attached string (picture) and now i want to get from every string in every column the word between the last \ and dot. So for example for the first column i would like to get Gös-Schb2_Ma142-Schb.
The problem is that i will have files later with a different pattern. So its important that i can find with the code the last backslash and dot. My code is:
pointLocation = strfind(A, '.');
underlineLocation = strfind(A, '\');
firstPart = A(underlineLocation(end):pointLocation(end));
But its not working at all...maybe u can help me?
Prudhvi Peddagoni 2021년 3월 8일
As Stephen Cobeldick pointed out. fileparts function does exactly what you are looking for. the second output, name, is the part of the string that is after last '/' and before last '.'. So you can get the strings from a table and give it to this function.
Hope this helps.