Skip to content

Instantly share code, notes, and snippets.

@rayman22201
Created July 15, 2018 05:24
Show Gist options
  • Save rayman22201/63d571e7c58bd496d4f299cc84da0bea to your computer and use it in GitHub Desktop.
Save rayman22201/63d571e7c58bd496d4f299cc84da0bea to your computer and use it in GitHub Desktop.
Nim re module bug
import re
let htm = """<P class=MsoNormal
style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; TEXT-AUTOSPACE: ; mso-pagination: none; mso-layout-grid-align: none"><B><SPAN
lang=de
style='FONT-SIZE: 33pt; FONT-FAMILY: "TimesNewRoman,Bold","serif"; mso-bidi-font-family: "TimesNewRoman,Bold"; mso-ansi-language: #0007'>Teil
II<o:p></o:p></SPAN></B></P>"""
var matchesSeq : seq[string] = @[]
echo match(htm, re("""\<P.*\#0007\'>(.*)\<\/P>""", {reMultiLine, reDotAll, reExtended}), matchesSeq)
echo "seq: ", matchesSeq # does not work. 0 results
var matchesArr : array[20, string]
echo match(htm, re("""\<P.*\#0007\'>(.*)\<\/P>""", {reMultiLine, reDotAll, reExtended}), matchesArr)
echo "array: ", matchesArr # does work. 1 result
if htm =~ re("""\<P.*\#0007\'>(.*)\<\/P>""", {reMultiLine, reDotAll, reExtended}):
echo "template (uses array): ", matches # does work. 1 result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment