I have a string h2#test- ruby is so awesome, blah, blah, blah
. I want to have #test
to be the only characters left. is there a way in ruby to run a Regular Expression that removes all other characters?
views:
56answers:
3Thanks, worked great!
errorhandler
2010-09-11 01:01:15
A:
Don't think of it as removing all other characters...think of it as capturing what you want.
'h2#test- ruby is so awesome, blah, blah, blah' =~ /(#test)/
your_captured_text = $1
Doug R
2010-09-11 00:54:18