Jump to content

Rosetta Code/Run examples: Difference between revisions

Updated the URL to get page content and updated the regular expression as "lang" has changed to "syntaxhighlight".
(→‎{{header|Wren}}: Wren script partially rewritten to deal with site changes.)
(Updated the URL to get page content and updated the regular expression as "lang" has changed to "syntaxhighlight".)
Line 628:
continue
 
let url = "https://rosettacode.org/mww/index.php?title=" & task & "&action=edit"
let body = client.getContent(url)
var lang: string
Line 643:
of "go":
lang2 = "Go"
lang3 = """("go"|"Go"|"GO")"""
ext = "go"
of "nim":
lang2 = "Nim"
lang3 = """("nim"|"Nim")"""
ext = "nim"
of "perl":
lang2 = "Perl"
lang3 = """("perl"|"Perl")"""
ext = "pl"
of "python":
lang2 = "Python"
lang3 = """("python"|"Python")"""
ext = "py"
 
let fileName = "rc_temp." & ext
let regexheader = re(r"(?s)==\{\{header\|$#\}\}==.*?<lang $#>(.*?)</lang>".format(lang2, lang3))
let language = r"lt;syntaxhighlight lang=$#>".format(lang3)
let regex = re(header & r"==.*?&" & language & r"(.*?)</syntaxhighlight>")
var matches: array[2, string]
let idx = body.find(regex, matches)
256

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.