Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Also, believe it or not, you could write a regex which matches all alphanumeric strings, except for "help". The regex <code>([a-zA-Z0-9]+)/?&amp;~help</code> can be rewritten to a regex which does not use the <code>&amp;</code> and <code>~</code> (and and not) operators (not widely available).</p> <p>The regex looks like dog's breakfast, and so you don't really want to do this. But here is how.</p> <p>Firstly, all shorter alphanumeric codes are matched. "hel" is acceptable problem and neither is any other three-letter/digit sequence:</p> <pre><code>[a-zA-Z0-9]{1,3} </code></pre> <p>We can also recognize sequences of five or more characters; they are not "help" either, by including this:</p> <pre><code>[a-zA-Z0-9]{5,} </code></pre> <p>Now comes the tricky part, matching four-letter sequences which are not help. This means any four char identifier that doesn't begin with an <code>h</code>, or any four char that does not have <code>e</code> as the second letter. Etc:</p> <pre><code>[a-gi-zA-Z0-9][a-zA-Z0-9]{3} [a-zA-Z0-9][a-df-zA-Z0-9][a-zA-Z0-9]{2} [a-zA-Z0-9]{2}[a-km-zA-Z0-9][a-zA-Z0-9] [a-zA-Z0-9]{3}[a-oq-zA-Z0-9] </code></pre> <p>The only four char pattern that does not match any one of these is the word "help". It doesn't match the first one because of the h, the second one because of the e, etc.</p> <p>So, combining them all together with | and anchoring. Take a deep breath:</p> <pre><code>^([a-zA-Z0-9]{1,3}|[a-zA-Z0-9]{5,}|[a-gi-zA-Z0-9][a-zA-Z0-9]{3}|[a-zA-Z0-9][a-df-zA-Z0-9][a-zA-Z0-9]{2}|[a-zA-Z0-9]{2}[a-km-zA-Z0-9][a-zA-Z0-9]|[a-zA-Z0-9]{3}[a-oq-zA-Z0-9])$ </code></pre> <p>This should be the new channel key for <code>#unix</code> on the EFNet IRC network. :)</p> <p>Am I gonna test this? What are you nuts ... </p> <p>Of course I did, but with sed. A little bit. Most of the meta chars have to be escaped, oops:</p> <pre><code>$ sed -n -e '/^\([a-zA-Z0-9]\{1,3\}\|[a-zA-Z0-9]\{5,\}\|[a-gi-zA-Z0-9][a-zA-Z0-9]\{3\}\|[a-zA-Z0-9][a-df-zA-Z0-9][a-zA-Z0-9]\{2\}\|[a-zA-Z0-9]\{2\}[a-km-zA-Z0-9][a-zA-Z0-9]\|[a-zA-Z0-9]\{3\}[a-oq-zA-Z0-9]\)$/p' a &lt;- typed a aa &lt;- typed aa aaa &lt;- aaa aaaa &lt;- aaaa aaaaa &lt;- aaaaa help &lt;- aha, no response from sed aelp &lt;- aelp helper &lt;- helper </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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