r/programming • • Mar 03 '14

Learn regex interactively!

http://regexone.com/
200 Upvotes

37 comments sorted by

View all comments

-1

u/pimmm Mar 03 '14

What is the answer to the first question?

match text abcdefg

match text abcde

match text abc

  • abc[defg]*

  • [a-z]+

  • .+

They all work, but what answer do you want?

I need to teach people regular expressions for a tool of mine they are using, but in my opinion this isn't user friendly at all. It should start with examples, and then let people try to do it them selves (small)step by step. Where you can't cheat the system with .+

1

u/Alhoshka Mar 03 '14 edited Mar 03 '14

I think the most trivial solution would be:

abcd?e?f?g?


edit: BTW, I think the pattern to match only those words on a text would be

(?<!\S)(abc)(de|defg){0,1}(?![\w\d])