Clean characters of strings in column

1 view (last 30 days)
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"

Accepted Answer

Walter Roberson
Walter Roberson on 27 Dec 2020
regexprep(Players, '\\.*', '')
  1 Comment
Kushal Kharel
Kushal Kharel on 27 Dec 2020
Thank you @Walter Roberson. I appreicate your support.

Sign in to comment.

More Answers (1)

Image Analyst
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
  1 Comment
Kushal Kharel
Kushal Kharel on 27 Dec 2020
Thank you image analyst but this code does not help. Walter code works perfectly. Thank you for your continuous support to me to learn MATLAB. I will be sharing my journey towards data science with you all who supported me.

Sign in to comment.

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!