I have strings that contain a variable number of leading hyphens and which may or may not contain a hyphen in the body of the string. For example:
–xxx-xxx
-xxxx
—xxxxxx-xx
How do I in Ruby a) count the number of leading hyphens and b) return the string with the leading hyphens removed?
Many thanks for your help!
EDIT: The comment from @shime made me want to show the other relevant capability of
String#[]orString#slice: