Timeline for How do you convert a string representing a finite set of strings into a regulair expression without using lots of vertical bars?
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 5, 2023 at 7:13 | comment | added | Stef | @SamuelMuldoon Anyway, there exist different libraries / algorithms designed specifically to build regexps from a list of strings. See for instance this related question or this github repository | |
| Apr 5, 2023 at 7:12 | comment | added | Stef | @SamuelMuldoon Importantly, note that "regular expression" typically has two distinct meanings. The theoretical meaning, where they are restricted to expressing regular languages; and the meaning from the programming world, whose regexps are like theoretical regexps but with many added superpowers. Here on this site, in the absence of more context, people are going to assume you mean regexps in the sense used in theory, not in the superpowered sense used in programming languages. | |
| Apr 5, 2023 at 1:23 | comment | added | Toothpick Anemone | @D.W. You said it might be helpful to provide the motivation for not allowing use of |, and for using a regexp for this. The reason is that in general, I want to convert sets containing thousands of strings into regular expressions so that the regular expressions are short in length. How do we find a reasonably short regex $r$ such that $\forall \sigma \in A$, $\sigma$ and regex $r$ match. Additionally, $\forall \sigma^{\prime} \in A^{-1}$, $\sigma^{\prime}$ and regex $r$ do not match. Note that $A$ is a set of strings and $\sigma$ is a string in set $A$. | |
| Apr 5, 2023 at 1:18 | history | edited | Toothpick Anemone | CC BY-SA 4.0 | I misspelled "representing" and made a few other mistakes in the original post |
| Apr 4, 2023 at 9:38 | answer | added | Stef | timeline score: 1 | |
| Apr 4, 2023 at 9:27 | comment | added | Stef | If Jordye was in the set too, then Joa+rd[iye]e+ would work, where [iye] means "one character which can be i, y or e", and a+ means "zero or one a". But without Jordye in the set I'm afraid you have to content with Joa+rd(i|y|e|ie|ee) or Joa+rd([iye]|[ie]e). | |
| Apr 4, 2023 at 3:55 | comment | added | D.W.♦ | I wonder if it might be helpful to provide the motivation for not allowing use of |, and for using a regexp for this. I wonder if this might be a XY problem, but it's hard to know. | |
| Apr 4, 2023 at 3:54 | comment | added | D.W.♦ | What do you mean by "a regular expression without the logical-disjunction vertical bar |"? | is part of the syntax of regular expressions. It's not clear what is allowed. If we take the standard syntax for regexps and remove |, all that is left is grouping ((...)) and Kleene star (*), which doesn't seem very expressive, but there are multiple different definitions of regexp syntax. Can you provide a self-contained definition of what you are looking for, and what definition of regular expression you are using and what syntax is allowed? | |
| Apr 4, 2023 at 3:00 | history | asked | Toothpick Anemone | CC BY-SA 4.0 |