Hi there,
please help me with my problem.
you want to create from “?X is parent of ?Y” ===>> “(\w+) is parent of
(\w+)”
I was trying something like:
“?X is parent of ?Y”.gsub(/?[A-Z]/) { “(\\w+)” }
“?X is parent of ?Y”.gsub(/?[A-Z]/) { “(\\w+)” }
“?X is parent of ?Y”.gsub(/?[A-Z]/) { “(\w+)” }
“?X is parent of ?Y”.gsub(/?[A-Z]/) { “(\w+)” }
but nothing,
thx in forward,
p.s.
irb 0.9.6(09/06/30)
ruby 1.9.3p125 (2012-02-16 revision 34643) [universal.x86_64-darwin10]
On Fri, Apr 13, 2012 at 2:38 PM, Jozef Rešetár [email protected]
wrote:
“?X is parent of ?Y”.gsub(/?[A-Z]/) { “(\\w+)” }
“?X is parent of ?Y”.gsub(/?[A-Z]/) { “(\w+)” }
“?X is parent of ?Y”.gsub(/?[A-Z]/) { “(\w+)” }
but nothing,
This works:
1.9.2p290 :001 > s = “?X is parent of ?Y”
=> “?X is parent of ?Y”
1.9.2p290 :002 > s.gsub(/?[A-Z]+/, “(\w+)”)
=> “(\w+) is parent of (\w+)”
1.9.2p290 :003 > puts s.gsub(/?\w+/, “(\w+)”)
(\w+) is parent of (\w+)
=> nil
Take note that what IRB returns is the inspect of the string, so you
see double backslashes. If you print it, you’ll see the unescaped
backslash character.
Jesus.