Hey everyone, I'm hoping someone can point me in the right direction.
<div><br></div><div>The regex-pcre package exports (=~) and (=~~) as two useful infix functions. They&#39;re great! The only problem is, they are a <i>positive</i> match for a regex. I have a file that contains HTML comments (it was generated in Word) and I really just want the barest text. I already have a function that strips out all the tags, and I have a function that finds all the links and sticks those in another file for later perusal.</div>
<div><br></div><div>What I&#39;d like is advice on how to implement the (!~) and (!~~) operators. They should have the same types as (=~) and (=~~). I&#39;m stuck, though. Here&#39;s the source for both of those functions: they depend on Text.Rege.PCRE package.</div>
<div><br></div><div><a name="v:-61--126-" class="def" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;font-weight:bold;font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">(=~)</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> :: (</span><a href="http://hackage.haskell.org/packages/archive/regex-base/0.93.2/doc/html/Text-Regex-Base-RegexLike.html#t:RegexMaker" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">RegexMaker</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> </span><a href="http://hackage.haskell.org/packages/archive/regex-pcre/0.94.2/doc/html/Text-Regex-PCRE-Wrap.html#t:Regex" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">Regex</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> </span><a href="http://hackage.haskell.org/packages/archive/regex-pcre/0.94.2/doc/html/Text-Regex-PCRE-Wrap.html#t:CompOption" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">CompOption</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> </span><a href="http://hackage.haskell.org/packages/archive/regex-pcre/0.94.2/doc/html/Text-Regex-PCRE-Wrap.html#t:ExecOption" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">ExecOption</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> source, </span><a href="http://hackage.haskell.org/packages/archive/regex-base/0.93.2/doc/html/Text-Regex-Base-RegexLike.html#t:RegexContext" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">RegexContext</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> </span><a href="http://hackage.haskell.org/packages/archive/regex-pcre/0.94.2/doc/html/Text-Regex-PCRE-Wrap.html#t:Regex" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">Regex</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> source1 target) =&gt; source1 -&gt; source -&gt; target</span> <br>
</div><div><pre><span class="hs-layout" style="color:red">(</span><span class="hs-varop">=~</span><span class="hs-layout" style="color:red">)</span> <span class="hs-varid">x</span> <span class="hs-varid">r</span> <span class="hs-keyglyph" style="color:red">=</span> <span class="hs-keyword" style="color:blue">let</span> <span class="hs-varid">q</span> <span class="hs-keyglyph" style="color:red">::</span> <span class="hs-conid">Regex</span>
<a name="line-155"></a>               <span class="hs-varid">q</span> <span class="hs-keyglyph" style="color:red">=</span> <span class="hs-varid">makeRegex</span> <span class="hs-varid">r</span>
<a name="line-156"></a>           <span class="hs-keyword" style="color:blue">in</span> <span class="hs-varid">match</span> <span class="hs-varid">q</span> <span class="hs-varid">x</span></pre></div><div><br></div><div><a name="v:-61--126--126-" class="def" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;font-weight:bold;font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">(=~~)</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> :: (</span><a href="http://hackage.haskell.org/packages/archive/regex-base/0.93.2/doc/html/Text-Regex-Base-RegexLike.html#t:RegexMaker" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">RegexMaker</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> </span><a href="http://hackage.haskell.org/packages/archive/regex-pcre/0.94.2/doc/html/Text-Regex-PCRE-Wrap.html#t:Regex" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">Regex</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> </span><a href="http://hackage.haskell.org/packages/archive/regex-pcre/0.94.2/doc/html/Text-Regex-PCRE-Wrap.html#t:CompOption" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">CompOption</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> </span><a href="http://hackage.haskell.org/packages/archive/regex-pcre/0.94.2/doc/html/Text-Regex-PCRE-Wrap.html#t:ExecOption" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">ExecOption</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> source, </span><a href="http://hackage.haskell.org/packages/archive/regex-base/0.93.2/doc/html/Text-Regex-Base-RegexLike.html#t:RegexContext" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">RegexContext</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> </span><a href="http://hackage.haskell.org/packages/archive/regex-pcre/0.94.2/doc/html/Text-Regex-PCRE-Wrap.html#t:Regex" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">Regex</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> source1 target, </span><a href="http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Control-Monad.html#t:Monad" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)">Monad</a><span style="font-family:monospace;font-size:13px;line-height:15px;text-align:left;background-color:rgb(240,240,240)"> m) =&gt; source1 -&gt; source -&gt; m target</span><br>
</div><div><pre><span class="hs-layout" style="color:red">(</span><span class="hs-varop">=~~</span><span class="hs-layout" style="color:red">)</span> <span class="hs-varid">x</span> <span class="hs-varid">r</span> <span class="hs-keyglyph" style="color:red">=</span> <span class="hs-keyword" style="color:blue">do</span> <span class="hs-layout" style="color:red">(</span><span class="hs-varid">q</span> <span class="hs-keyglyph" style="color:red">::</span> <span class="hs-conid">Regex</span><span class="hs-layout" style="color:red">)</span> <span class="hs-keyglyph" style="color:red">&lt;-</span>  <span class="hs-varid">makeRegexM</span> <span class="hs-varid">r</span>
<a name="line-160"></a>               <span class="hs-varid">matchM</span> <span class="hs-varid">q</span> <span class="hs-varid">x</span></pre><pre>What I figured I could do was find a function that was the inverse of &quot;match&quot; and &quot;matchM&quot;, but I can&#39;t find any in the docs. I really hope I don&#39;t have to implement <i>that</i>, too. I&#39;m still new at this, and that seems like it would be over my head.</pre>
</div>