Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My solution is this:</p> <pre><code>^(([a-zA-Z0-9äöüÄÖÜ]+(-[a-zA-Z0-9äöüÄÖÜ]+)?\s)*([a-zA-Z0-9äöüÄÖÜ]*\.)| (\.[a-zA-Z0-9äöüÄÖÜ]+))|((([a-zA-Z0-9äöüÄÖÜ]*\.)|(\.[a-zA-Z0-9äöüÄÖÜ]+)\s)? ([a-zA-Z0-9äöüÄÖÜ]+(-[a-zA-Z0-9äöüÄÖÜ]+)?\s)*[a-zA-Z0-9äöüÄÖÜ]+ (-[a-zA-Z0-9äöüÄÖÜ]+)?)$ </code></pre> <p><strong>Breaking it down</strong></p> <p>A dot-free word with hyphen matches: Its assumed that a hyphen, if present, is not allowed at the beginning or the end. If this assumption is wrong, it is easy enough to adjust accordingly.</p> <pre><code>[a-zA-Z0-9äöüÄÖÜ]+-[a-zA-Z0-9äöüÄÖÜ]+ </code></pre> <p>A dot-free word without hyphen matches:</p> <pre><code>[a-zA-Z0-9äöüÄÖÜ]+ </code></pre> <p>Thus a dot-free word, with or without a single hyphen (and at most one hypen) matches:</p> <pre><code>[a-zA-Z0-9äöüÄÖÜ]+(-[a-zA-Z0-9äöüÄÖÜ]+)? </code></pre> <p>We can make use of a general design pattern (no pun intended), to get exactly one X with any number of Y:</p> <pre><code>(Y*X)|(XY+) </code></pre> <p>So applying this rule, a dotted word with exactly one dot matches:</p> <pre><code>([a-zA-Z0-9äöüÄÖÜ]*\.)|(\.[a-zA-Z0-9äöüÄÖÜ]+) </code></pre> <p>Similarly get a stream of words with exactly one dotted, we slightly modify the general rule for a space separator. So a stream of words with exactly one dotted matches:</p> <pre><code> ((Y\s)*X)|(X\s(Y\s)*Y) </code></pre> <p>where: 1. Y = the regex for a dot-free word 2. X = the regex for a dotted word </p> <p>Similarly a stream of only dot-free words would match:</p> <pre><code>(Y\s)*Y </code></pre> <p>where Y is as before.</p> <p>Combining the two meta-regexes, a stream of words with at most one dotted word matches:</p> <pre><code>((Y\s)*X)|((X\s)?(Y\s)*Y) </code></pre> <p>where X and Y are as before.</p> <p>The final step is to substitute X and Y back in the preceding meta-regex to yield my propoosed solution. The really nice thing about my solution is that it does not use look-aheads, so resolution is faster and it works on all flavours of regex, including even the very primitive flavours from XML Schema, XPATH and XSLT.</p> <p>Add ^ and $ at the start and end if needed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload