Forum: Ruby how i can get value in string with pattern

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0bd58a270274beb1f62b62da2cd89d41?d=identicon&s=25 Jakov (Guest)
on 2006-04-18 11:42
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.
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-04-18 11:54
(Received via mailing list)
"Who is this (//mystring//)".scan(Regexp.new('//(.*)//')).first.first
#=> "mystring"
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2006-04-18 11:57
(Received via mailing list)
2006/4/18, Jakov <arlan@aport2000.ru>:
> 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
0bd58a270274beb1f62b62da2cd89d41?d=identicon&s=25 Jakov (Guest)
on 2006-04-18 12:17
thanks, for all
This topic is locked and can not be replied to.