Here is an example:
s.match(/+[^@]*/)
Result => "+subtext"
The thing is, i do not want to include "+" in there. I want the result to be "subtext", with out the +
Here is an example:
s.match(/+[^@]*/)
Result => "+subtext"
The thing is, i do not want to include "+" in there. I want the result to be "subtext", with out the +
You could use a positive lookbehind assertion, which I believe is written like this:
s.match(/(?<=\+)[^@]*/)
EDIT: So I just noticed this is a Ruby question, and I don't know if this feature is in Ruby (I'm not a Ruby programmer myself). If it is, you can use it; if not... I'll delete this.
You can use parentheses in the regular expression to create a match group:
s="[email protected]"
s =~ /\+([^@]*)/ && $1
=> "subtext"
I don't know Ruby very well, but if you add capturing around the portion you want it should work. ie: \+([^@]*)
You can test these with Rubular. This specific match is here: http://www.rubular.com/r/pqFza9jlmX
This works for me:
\+([^@]+)
I like to use Rubular for playing around with regular expressions. Makes debugging a lot easier.