Using Ruby + regex, given:
I want to obtain just: 31313131313
ie, what is between starting-middle+
and mysite.com
Here's what I have so far:
to = '[email protected]'
to.split(/\+/@mysite.com.*/).first.strip
Between 1st +
and 1st @
:
to[/\+(.*?)@/,1]
Between 1st +
and last @
:
to[/\+(.*)@/,1]
Between last +
and last @
:
to[/.*\+(.*)@/,1]
Between last +
and 1st @
:
to[/.*\+(.*?)@/,1]
Here is a solution without regex (much easier for me to read):
i = to.index("+")
j = to.index("@")
to[i+1..j-1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With