So I'm aware that I can remove the last word from a string of words by using lastIndexOf(" "), but I'd like to add the condition that the word should only be removed if it contains an integer 0-9.
I'm asking because I'd like to separate company names from their reference tags (if such tags exist) for a list of data. These reference tags are guaranteed to contain at least one integer 0-9. For example, I have the string "Cisco Systems RX4510", and I'd like to remove the "RX4510" to just get the company name, "Cisco Systems." However, for another string "Electronic Arts", which has no reference tag, I just leave it alone.
Any help would be appreciated, thanks.
Aucun commentaire:
Enregistrer un commentaire