I am looking for the name (definition?) of X in:

A regular expression is X iff it has exactly one possible match.

Examples: <empty regex>, abc, \., [.], a|a, a{8,8}, \Q.*?\E
Counterexamples: ., a*, a|b, \d, a?

I would call such a regex constant. Can I use this name? Is there a similar concept?

Additionally, I would say a regex is literal iff it is constant and the single match is equal to the regex itself (f.e. a but not [a]).

NB: I would greatly appreciate some references, because I would like to cite them.

Research done: Check if a regex is ambiguous uses "ambiguous" but in another way ("a string can be matched by more that one ways from 1 regex")
I have asked it on math SE but was redirected here.

  • $\begingroup$ Those examples seem to indicate that you are interested in patterns interpreted by various commonly-used regex libraries, rather than regular expressions as part of formal language theory (in which most of those examples are meaningless). $\endgroup$ – rici Aug 28 '20 at 2:38
  • $\begingroup$ Yes, it is intended for practical purposes, specifically I want to reason about specific Java regexes (patterns), but I don't really care about the specific regex syntax implementation that much, more about the property of that specific regular expression, a.k.a pattern (not property of regular language) that says: this here regex matches one and only one input. $\endgroup$ – Hawk Aug 28 '20 at 3:20
  • $\begingroup$ Or maybe there is something like "this regex describes a singleton regular language"? Preferably I am looking for somehting less wordy $\endgroup$ – Hawk Aug 28 '20 at 3:29
  • $\begingroup$ $|L(R)|= 1$ :-) I suppose "singleton" covers it fine. I'd say "this regex matches one string" (something which rarely comes up in my experience, but I guess your use case is different). $\endgroup$ – rici Aug 28 '20 at 4:24
  • $\begingroup$ Please post an answer (preferably with how would you read that out loud). BTW if you are interested, I need it in the field of DSL construction, where I am essentially reverse-engineering a regex token to know if I can use the single match specially (f.e. as an alias for the concept). Tokens are "singleton" regexes more often than not, actually. $\endgroup$ – Hawk Aug 28 '20 at 4:53

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.