lpil / elixre

🦑 An Elixir regular expression editor & tester, with Elm
http://elixre.lpil.uk/
GNU Affero General Public License v3.0
101 stars 10 forks source link

Negative lookahead doesn't work correctly #20

Closed indiejames closed 9 years ago

indiejames commented 9 years ago

screen shot 2015-04-11 at 10 54 37 pm

lpil commented 9 years ago

Thanks :)

So it's matching the second abc, but not the first. Hm. Regex.run doesn't tell us the index of the match, the client just looks for the first instance of the match in the string.

Perhaps there's another function we can use to get the index, otherwise this is going to be a tricky to fix.

lpil commented 9 years ago
Regex.run ~r/abc(?!.*abc)/, "abcghjkabchj", return: :index
# [{7, 3}]
lpil commented 9 years ago

There we go :)

indiejames commented 9 years ago

Nice, thanks. I didn't now about return: :index.

lpil commented 9 years ago

Me either ;)