You can use the split()
method and array indexing to achieve this:
index.tsx109 chars4 lines
Alternatively, you can use the substr()
method to extract the second part of the string based on the index of the hyphen:
index.tsx142 chars4 lines
Note that if your string contains multiple hyphens and you want to always select the second part, you can use a regular expression to match the second group of non-hyphen characters:
index.tsx119 chars4 lines
gistlibby LogSnag