Вот так, как на сайте:
text1 := "<>"
text2 =
(
<ProcessTextResult>
— Это "Типограф"?
<ProcessTextResult>
— Нет, это «Типограф»!
)
Typograf := new Typograf
MsgBox, % Typograf.Process(text1)
MsgBox, % Typograf.Process(text2)
MsgBox, % Typograf.Process(text2, true) ; с переносом строк
class Typograf {
__New() {
this.xmlhttp := ComObjCreate("Msxml2.XMLHTTP")
this.WaitForResponse := ObjBindMethod(this, "Ready")
}
Process(text, useBr := false) {
text := this.Replace(text)
xmlRequest := "<?xml version=""1.0"" encoding=""UTF-8""?>"
. "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"""
. " xmlns:xsd=""http://www.w3.org/2001/XMLSchema"""
. " xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
. "<soap:Body>"
. "<ProcessText xmlns=""http://typograf.artlebedev.ru/webservices/"">"
. "<text>" . text . "</text>"
. "<useP>0</useP>"
. "<useBr>" . useBr . "</useBr>"
. "</ProcessText></soap:Body></soap:Envelope>"
url := "http://typograf.artlebedev.ru/webservices/typograf.asmx"
this.xmlhttp.Open("POST", url, true)
this.xmlhttp.onreadystatechange := this.WaitForResponse
this.xmlhttp.setRequestHeader("Content-Type", "text/xml")
this.xmlhttp.Send(xmlRequest)
while this.result = ""
Sleep, 200
res := RegExReplace(this.result, "s).*<ProcessTextResult>(.*)</ProcessTextResult>.*", "$1")
this.result := ""
Return this.Replace(res, false)
}
Ready() {
if this.xmlhttp.readyState != 4
Return
this.result := this.xmlhttp.ResponseText
}
Replace(text, direction := true) {
for k, v in direction ? [["&", "&"], ["<", "<"], [">", ">"]] : [["<", "<"], [">", ">"], ["&", "&"]]
text := StrReplace(text, v[1], v[2])
Return text
}
}
Только, если как в примере, тогда то, что в тегах (в угловых скобках), вообще удалится:
text = text.replace (/<[^>]+>/g, '');
Разработка AHK-скриптов:
e-mail
dfiveg@mail.ruTelegram
jollycoder