I'm trying to match characters before and after a symbol, in a string.
string: budgets-closed
To match the characters before the sign -
, I do: ^[a-z]+
And to match the other characters, I try: \-(\w+)
but, the problem is that my result is: -closed
instead of closed
.
Any ideas, how to fix it?
Update
This is the piece of code, where I was trying to apply the regex http://jsfiddle.net/trDFh/1/
I repeat: It's not that I don't want to use split; it's just I was really curious, and wanted to see, how can it be done the regex way. Hacking into things spirit
Update2
Well, using substring
is a solution as well: http://jsfiddle.net/trDFh/2/ and is the one I chosed to use, since the if in question, is actually an else if
in a more complex if
syntax, and the chosen solutions seems to be the most fitted for now.