How i can get value in string with pattern

how i can get value in string with pattern or regular experssion

I have this string:

“Who is this (//mystring//)”.gsub(?, “”)

How i can get ‘mystring’ if it’s conclude in mystring.

“Who is this (//mystring//)”.scan(Regexp.new(’//(.*)//’)).first.first
#=> “mystring”

2006/4/18, Jakov [email protected]:

how i can get value in string with pattern or regular experssion

I have this string:

“Who is this (//mystring//)”.gsub(?, “”)

How i can get ‘mystring’ if it’s conclude in mystring.

p “Who is this (//mystring//)”.scan(%r{//(\w+)//}).map{|m| m[0]}

s = %r{//(\w+)//} =~ “Who is this (//mystring//)” && $1
p s

Cheers

robert

thanks, for all

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs