Hacker News new | past | comments | ask | show | jobs | submit login

No. "a" produces a match when run on "a" and "bad" and "aaaa" and many more things.

The regex ^a$ only matches "a", but it doesn't match itself.




That isn't a match...

I can still see the neat aspect of the post. But that is not a match.


What do you mean?


Regex libraries often distinguish between a string containing a regex, and matching it.

The string "aaaa" is a Regular Expression that describes a language with exactly one string: "aaaa".

Some regular expression libraries have two operations: They can tell you if a string contains a match somewhere within it, or is exactly a match. Some other libraries only do the first operation, and you need to explicitly ask for "^aaaa$" to get an exact match.

This is one of the things on the differences between the formal definition of a Regular Expression, and a regex library.


Yeah. I want trying to be a jerk. Pedantic some, but I thought the difference between match and find was pretty general in regex land.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: