Clean characters of strings in column

1 visualizzazione (ultimi 30 giorni)
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"

Risposta accettata

Walter Roberson
Walter Roberson il 27 Dic 2020
regexprep(Players, '\\.*', '')

Più risposte (1)

Image Analyst
Image Analyst il 27 Dic 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 Commento
Kushal Kharel
Kushal Kharel il 27 Dic 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.

Accedi per commentare.

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by