str="Dont know what I want but I know how to get it" ap str ap str[/(\w+) want/] ap str[/(?<a>\w+) want/, :a] /(?<a>\w+) want/ =~ str ap a