ruby, using regex to find something in between two strings

后端 未结 4 483
醉话见心
醉话见心 2021-02-04 06:37

Using Ruby + regex, given:

starting-middle+31313131313@mysite.com

I want to obtain just: 31313131313

ie, what is between

4条回答
  •  一个人的身影
    2021-02-04 07:33

    Here is a solution without regex (much easier for me to read):

    i = to.index("+")
    j = to.index("@")
    to[i+1..j-1]
    

提交回复
热议问题