Patterns on OBITools4 documentation http://metabar:8888/obidoc/docs/patterns/ Recent content in Patterns on OBITools4 documentation Hugo en-us Regular Expressions http://metabar:8888/obidoc/docs/patterns/regular/ Mon, 01 Jan 0001 00:00:00 +0000 http://metabar:8888/obidoc/docs/patterns/regular/ <h1 id="regular-expressions"> Regular Expressions <a class="anchor" href="#regular-expressions">#</a> </h1> <p>Regular expressions are a powerful tool for describing patterns in text. They are used in several <abbr title="A set of unix command line tools for manipulating DNA metabarcoding data">OBITools</abbr> like <a href="http://metabar:8888/obidoc/obitools/obigrep/"> <abbr title="obigrep: filter a sequence file"><code>obigrep</code></abbr> </a>, <a href="http://metabar:8888/obidoc/obitools/obiannotate/"> <abbr title="obiannotate: edit sequence annotations"><code>obiannotate</code></abbr> </a> or <a href="http://metabar:8888/obidoc/obitools/obiscript/"> <abbr title="obiscript: apply a LUA script to a sequence file"><code>obiscript</code></abbr> </a>.</p> <h2 id="single-characters"> Single characters <a class="anchor" href="#single-characters">#</a> </h2> <table> <thead> <tr> <th>Pattern</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>.</code></td> <td>any character, possibly including newline (flag s=true)</td> </tr> <tr> <td><code>[xyz]</code></td> <td>character class</td> </tr> <tr> <td><code>[^xyz]</code></td> <td>negated character class</td> </tr> <tr> <td><code>[[:alpha:]]</code></td> <td>ASCII character class</td> </tr> <tr> <td><code>[[:^alpha:]]</code></td> <td>negated ASCII character class</td> </tr> </tbody> </table> <h2 id="composites"> Composites <a class="anchor" href="#composites">#</a> </h2> <table> <thead> <tr> <th>Pattern</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>xy</code></td> <td>x followed by y</td> </tr> <tr> <td><code>x|y</code></td> <td>x or y (prefer x)</td> </tr> </tbody> </table> <h2 id="repetitions"> Repetitions <a class="anchor" href="#repetitions">#</a> </h2> <table> <thead> <tr> <th>Pattern</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>x*</code></td> <td>zero or more x, prefer more</td> </tr> <tr> <td><code>x+</code></td> <td>one or more x, prefer more</td> </tr> <tr> <td><code>x?</code></td> <td>zero or one x, prefer one</td> </tr> <tr> <td><code>x{n,m}</code></td> <td>n or n+1 or &hellip; or m x, prefer more</td> </tr> <tr> <td><code>x{n,}</code></td> <td>n or more x, prefer more</td> </tr> <tr> <td><code>x{n}</code></td> <td>exactly n x</td> </tr> <tr> <td><code>x*?</code></td> <td>zero or more x, prefer fewer</td> </tr> <tr> <td><code>x+?</code></td> <td>one or more x, prefer fewer</td> </tr> <tr> <td><code>x??</code></td> <td>zero or one x, prefer zero</td> </tr> <tr> <td><code>x{n,m}?</code></td> <td>n or n+1 or &hellip; or m x, prefer fewer</td> </tr> <tr> <td><code>x{n,}?</code></td> <td>n or more x, prefer fewer</td> </tr> <tr> <td><code>x{n}?</code></td> <td>exactly n x</td> </tr> </tbody> </table> <h2 id="grouping"> Grouping <a class="anchor" href="#grouping">#</a> </h2> <table> <thead> <tr> <th>Pattern</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>(re)</code></td> <td>numbered capturing group (submatch)</td> </tr> <tr> <td><code>(?P&lt;name&gt;re)</code></td> <td>named &amp; numbered capturing group (submatch)</td> </tr> <tr> <td><code>(?&lt;name&gt;re)</code></td> <td>named &amp; numbered capturing group (submatch)</td> </tr> <tr> <td><code>(?:re)</code></td> <td>non-capturing group</td> </tr> <tr> <td><code>(?flags)</code></td> <td>set flags within current group; non-capturing</td> </tr> <tr> <td><code>(?flags:re)</code></td> <td>set flags during re; non-capturing</td> </tr> </tbody> </table> <h2 id="character-classes"> Character classes <a class="anchor" href="#character-classes">#</a> </h2> <table> <thead> <tr> <th>Pattern</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>[\d]</code></td> <td>digits (== \d)</td> </tr> <tr> <td><code>[^\d]</code></td> <td>not digits (== \D)</td> </tr> <tr> <td><code>[\D]</code></td> <td>not digits (== \D)</td> </tr> <tr> <td><code>[^\D]</code></td> <td>not not digits (== \d)</td> </tr> <tr> <td><code>[[:name:]]</code></td> <td>named ASCII class inside character class (== [:name:])</td> </tr> <tr> <td><code>[^[:name:]]</code></td> <td>named ASCII class inside negated character class (== [:^name:])</td> </tr> <tr> <td><code>[\p{Name}]</code></td> <td>named Unicode property inside character class (== \p{Name})</td> </tr> <tr> <td><code>[^\p{Name}]</code></td> <td>named Unicode property inside negated character class (== \P{Name})</td> </tr> </tbody> </table> <h2 id="named-character-classes"> Named character classes <a class="anchor" href="#named-character-classes">#</a> </h2> <table> <thead> <tr> <th>Pattern</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>[[:alnum:]]</code></td> <td>alphanumeric (== <code>[0-9A-Za-z]</code>)</td> </tr> <tr> <td><code>[[:alpha:]]</code></td> <td>alphabetic (== <code>[A-Za-z]</code>)</td> </tr> <tr> <td><code>[[:ascii:]]</code></td> <td>ASCII (== <code>[\x00-\x7F]</code>)</td> </tr> <tr> <td><code>[[:blank:]]</code></td> <td>blank (== <code>[\t ]</code>)</td> </tr> <tr> <td><code>[[:cntrl:]]</code></td> <td>control (== <code>[\x00-\x1F\x7F]</code>)</td> </tr> <tr> <td><code>[[:digit:]]</code></td> <td>digits (== <code>[0-9]</code>)</td> </tr> <tr> <td><code>[[:graph:]]</code></td> <td>graphical (== <code>[!-~]</code> == <code>[A-Za-z0-9!&quot;#$%&amp;'()*+,\-./:;&lt;=&gt;?@[\\\]^_`{|}~])</code></td> </tr> <tr> <td><code>[[:lower:]]</code></td> <td>lower case (== <code>[a-z]</code>)</td> </tr> <tr> <td><code>[[:print:]]</code></td> <td>printable (== <code>[ -~]</code> == <code>[[:graph:]]</code>)</td> </tr> <tr> <td><code>[[:punct:]]</code></td> <td>punctuation (== <code>[!-/:-@[-\`{-~]</code>)</td> </tr> <tr> <td><code>[[:space:]]</code></td> <td>whitespace (== <code>[\t\n\v\f\r ]</code>)</td> </tr> <tr> <td><code>[[:upper:]]</code></td> <td>upper case (== <code>[A-Z]</code>)</td> </tr> <tr> <td><code>[[:word:]]</code></td> <td>word characters (== <code>[0-9A-Za-z_]</code>)</td> </tr> <tr> <td><code>[[:xdigit:]]</code></td> <td>hex digit (== <code>[0-9A-Fa-f]</code>)</td> </tr> </tbody> </table> DNA Patterns http://metabar:8888/obidoc/docs/patterns/dnagrep/ Mon, 01 Jan 0001 00:00:00 +0000 http://metabar:8888/obidoc/docs/patterns/dnagrep/ <h1 id="dna-patterns"> DNA Patterns <a class="anchor" href="#dna-patterns">#</a> </h1> <p>DNA patterns are useful for describing short DNA sequences like oligonucleotides. They are used by several <abbr title="A set of unix command line tools for manipulating DNA metabarcoding data">OBITools</abbr> like <a href="http://metabar:8888/obidoc/obitools/obimultiplex/"> <abbr title="obimultiplex: "><code>obimultiplex</code></abbr> </a>, <a href="http://metabar:8888/obidoc/obitools/obipcr/"> <abbr title="obipcr: the electronic PCR tool"><code>obipcr</code></abbr> </a> or <a href="http://metabar:8888/obidoc/obitools/obigrep/"> <abbr title="obigrep: filter a sequence file"><code>obigrep</code></abbr> </a>. The advantage of using DNA patterns over classical regular expressions is that they can be matched with errors. Allowed errors can be simple mismatches, or mismatches and insertions/deletions.</p>