I read a message from the old Stata listserver that there was a way to remove the last word of a string using regex. (The words are separated by whitespaces.) The code for this is:
What does the
mean? How does this get the last word in a string? In particular, I don't understand what it means for the anchor character ^ to be inside the square brackets, which denote the set of allowable characters.
Code:
regexr(string, " [^ ]+$", "")
Code:
" [^ ]+$"
Comment