How do I split a string into two strings using a space + number delimiter and/or search for the delimiter by counting right to left?
Show older comments
Hello,
I have data entries that look like this:
Column 1 | Column 2
Default | 8
Default 2 | 9
Default 3 | 3
Default 4 | 5
Card 1 | 6
Card 1 2 | 10
Card 1 3 | 3
Card 1 4 | 2
Card 1 5 | 9
Card 1 6 | 3
Card 2 | 2
Card 2 2 | 2
Card 2 3 | 6
Card 2 4 | 8
Card 2 5 | 6
Card 2 6 | 9
I want to be able to split all the column 1 entries into two columns, the base part and the number. The number I'm interested in is ONLY the last number after the last space. The base part is allowed to have a number in it.
The only common thing between all the entries is that they end with [space][number] and number can be between 1 and 10000.
For the entries similar to the (1,1) entry above, I need to get a 0 at the end of that string as well.
I think I can use 'strsplit' or 'regexp' to do this, but I'm not sure how to tell Matlab that I need it to split at the end of the string effectively (have it count in from the right).
Thanks for any assistance you are able to give,
Matt
Accepted Answer
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!