First question, and my apologies if it is off-topic! This question suggests to me I may not be totally off-base.

Where did our present regex notation originate? I am particularly wondering how $ came to mean "end," particularly since its most common use in the English-speaking world (as far as I know) is as a prefix to numbers. I also wonder about . for "any".

* I know came directly from Kleene, and + seems like a logical extension of *, if only because they are closely related in mathematics.

I have been several pages down in a couple different Google Web and Scholar searches. I have also looked here and on SO and softwareengineering.SE, but I can't find an answer. I checked Perl 6's Apocalypse 5, but it doesn't explain how we got our present notation. I seem to recall that Kernighan's Software Tools might have had some information, but I can't put my hands on a copy at the moment. Thank you!

Edit Another data point - TECO dates from 1962, and terminated input strings with Esc, displayed as $ (source). Unfortunately,

the Escape character ... is written as "$" (for historical reasons, of course).

Id. That considerably predates UNIX v3 (1973), but doesn't explain the then-existing "historical reasons."

  • 1
    $\begingroup$ I'm not sure this is the best forum for this question – perhaps stackoverflow is better. $\endgroup$ Jun 29 '17 at 17:42
  • $\begingroup$ @YuvalFilmus Thanks for the feedback! I didn't ask on SO because there's no MCVE for this question :) . Specifically, the SO tour says that "anything not directly related to writing computer programs" is off-topic there. Do you have any other ideas for where I could ask? Much appreciated! $\endgroup$
    – cxw
    Jun 29 '17 at 18:30
  • 2
    $\begingroup$ I would suggest that this might have a place in this forum. One question is whether this use of the "$" symbol has an origin in the academic/theoretical literature (e.g.: regular events) that predates Ken Thompson's use of it in the ed text editor circa 1970. $\endgroup$
    – mhum
    Jun 29 '17 at 18:57
  • $\begingroup$ Also + is in use in algebra, just as * is, this was not invented for regular expressions. A^* is the free monoid, A^+ the free semigroup over the set A. $\endgroup$ Jun 30 '17 at 10:03
  • 6
    $\begingroup$ I don't think this is a computer science question. The regular expressions used by software packages and programming languages are fundamentally different from the ones used in computer science. For example, in CS, we always compare the whole string against the regular expression whereas, in software systems, we usually have to use something like ^...$ to force comparison against the whole string, rather than any substring. I think a question about CS notation would be fine, but this isn't a question about CS notation. $\endgroup$ Apr 16 '18 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.