title: Building expression from list of numbers
body: <p>I have a variable list of number (switch ports) that I need to build into a string that indicates which ports should be &quot;included&quot; and which should be &quot;excluded&quot;.
  Here is an example of the required format:</p>
  <pre><code>(Port 1[!(0-2 | 4-9)] | Port 4[!(0-3 | 5)])*
  </code></pre>
  <p>In this example, if my numbers are 1-19 and 40-45, then Port 1, Port 3, and Port 44 will be included while ports 10-12, 14-19, 40-43, and 45 will be excluded.</p>
  <p>I do not know, in advance, what numbers will be present in the port list. How can I build this expression?</p>