Clean characters of strings in column
1 view (last 30 days)
Show older comments
Kushal Kharel
on 27 Dec 2020
Commented: Kushal Kharel
on 27 Dec 2020
Hello Everyone,
I downloaded and loaded a dataset for NBA players. I would like to clean column Players to get just player names in that column. How would I do that? I have shown sample of output below. This is a second column from my table.
PLAYER
"Steven Adams\adamsst01"
"Bam Adebayo\adebaba01"
"LaMarcus Aldridge\aldrila01"
"Kyle Alexander\alexaky01"
"Nickeil Alexander-Walker\alexani01"
"Grayson Allen\allengr01"
"Jarrett Allen\allenja01"
"Kadeem Allen\allenka01"
"Al-Farouq Aminu\aminual01"
"Justin Anderson\anderju01"
"Kyle Anderson\anderky01"
0 Comments
Accepted Answer
More Answers (1)
Image Analyst
on 27 Dec 2020
for k = 1 : length(players)
thisPlayer = players{k}; % get this string.
slashLocation = find(thisPlayer == '\', 1, 'first') % Find location of slash
if ~isempty(slashLocation)
players{k} = thisPlayer(1 : slashLocation-1); % if a slash was found, take up until just before that slash location.
end
end
See Also
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!