Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which programming languages are regular? [closed]

The typical response to any "why isn't this regex working html!?!" question is "because HTML isn't a regular language".

So, I was curious if anyone had a list of common programming languages which were regular languages, and thus are appropriate for regular expression matching. I know there are ways to determine if a language is regular (case by case), but for complicated languages the proof can be also quite complicated. I thought perhaps a quick check list of languages could be useful.

I also know that you can do regular expressions with non-regular languages, but that they aren't always reliable (html example).

like image 471
Nick Bartlett Avatar asked Sep 06 '25 03:09

Nick Bartlett


1 Answers

Disregarding any arbitrary limits on nesting or programming length, I doubt any common programming languages are regular. Even simple (infix) arithmetical expressions form a non-regular language, and it is an unusual programming language that does not support them. More generally, if a language allows nesting of any construct without limiting its depth, it is not a regular language.

like image 200
ibid Avatar answered Sep 07 '25 21:09

ibid