Hacker News new | ask | show | jobs
by chrisseaton 2080 days ago
* is the wildcard in some forms of regular expressions, such as file name globs.
2 comments

I know that * is the wildcard in many expressions, such as some query languages and (as you say) file name globs. However, I don't actually think a wildcard glob is a regular expression. Wikipedia, always a risky source :-), makes that point, with a reference to further reading.

The article is about the asterisk character, and the connection to the wild-card seems legit. But the sentence "I find regular expressions can induce swearing, occasionally" (which I agree fully with!) hints towards the idea that the * is used as a wildcard in regular expressions, which I think isn't quite true.

[1] https://en.wikipedia.org/wiki/Glob_(programming)#Compared_to...

A glob isn't a regular expression, and indeed one of the reasons it isn't is that it lacks the Kleene star - which is the thing an asterisk does in the typical regular expression syntax.
I don't think you need the Kleene star to be regular.

Star-free languages are regular languages without the Kleene star.

https://en.wikipedia.org/wiki/Star-free_language

But I'm not an expert in formal languages and maybe you are.

I think you're slightly at cross-purposes: GP is saying that since globs lack the Kleene star, they cannot be used to define all regular languages.

Star-free languages are a strict subset of the set of regular languages, so there exist regular languages that require the Kleene star to be represented as a regular expression; indeed the Wikipedia article you linked gives an example.

It's perhaps worth noting that neither regular expressions nor globs are themselves regular languages: they are just used to define regular languages. Consider that regular expressions usually require some form of parenthetical notation, and that languages with matched parentheses cannot be regular as a trivial consequence of the pumping lemma.