Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Hi I need a Regex that can actually get any letter that is inserted after "-" dash e.g i have a string that says

 "UpTown-R" , "Category-C"

What I get in return is "R" , "C".

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
273 views
Welcome To Ask or Share your Answers For Others

1 Answer

If is always the last part of the string, you can do this

/[^-]+$/

see it here on Regexr

[^-] is a character class that matches everything that is not a dash

+ quantifier means one or more of the preceding element

$ anchor for the end of the string


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...