Live data from Hacker News

Regex that only matches itself

codegolf.stackexchange.com

11–20 of 66 posts

Re: Regex that only matches itself

#14

I think I might be missing something. Wouldn't something like "a" be a valid 1-byte regular expression that only matches instances of "a"?

> NOTE, delimiters must be included Your regex is actually /a/ which does not match the string "/a/".

Ahh. Thank you.

Re: Regex that only matches itself

#17

I think I might be missing something. Wouldn't something like "a" be a valid 1-byte regular expression that only matches instances of "a"?

> NOTE, delimiters must be included Your regex is actually /a/ which does not match the string "/a/".

I would say that adding slashes is quite arbitrary constraint, and it is really language specific syntax that is limited to minority of languages (I believe it was introduced in Perl). If you do regexp in Java, Python, C you don't use slashes.

Edit: looks like slashes weren't even used in the example.

Re: Regex that only matches itself

#19
post #17

Earlier quoted context omitted.

> NOTE, delimiters must be included Your regex is actually /a/ which does not match the string "/a/".

I would say that adding slashes is quite arbitrary constraint, and it is really language specific syntax that is limited to minority of languages (I believe it was introduced in Perl). If you do regexp in Java, Python, C you don't use slashes. Edit: looks like slashes weren't even used in the example.

It's a pretty boring question if you don't make that requirement, though. The whole exercise is arbitrary, so it doesn't bother me.

Re: Regex that only matches itself

#20
post #3

I wish I was as smart as these people.

Everybody is a Genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

Probably not Einstein http://quoteinvestigator.com/2013/04/06/fish-climb/ (not that it matters in any deep way).
Post reply on HN