News for hackers. Stuff that matters.
Re:Regex that only matches itself by TheDong on Friday November 11, 2016 @03:33PM (#12934067)
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.

Re:Regex that only matches itself by taeric on Friday November 11, 2016 @03:38PM (#12934106)
That isn't a match...

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

Re:Regex that only matches itself by bertiewhykovich on Friday November 11, 2016 @03:58PM (#12934276)
What do you mean?
Re:Regex that only matches itself by mcpherrinm on Friday November 11, 2016 @04:15PM (#12934400)
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.

Re:Regex that only matches itself by taeric on Friday November 11, 2016 @06:19PM (#12935377)
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.