Note that (\S+) refers to \2 as well as $2.
line = "some strings are identical and some strings are not identical" line.scan(/(^|\s)(\S+)(?=\s.*?\2)/) { puts $2 }
11382 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
line = "some strings are identical and some strings are not identical" line.scan(/(^|\s)(\S+)(?=\s.*?\2)/) { puts $2 }
You need to create an account or log in to post comments to this site.