How i can get value in string with pattern


#1

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.


#2

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


#3

2006/4/18, Jakov removed_email_address@domain.invalid:

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


#4

thanks, for all