gpt4 book ai didi

string - 有没有办法在lua(原始)中定义自动转义字符串?

转载 作者:行者123 更新时间:2023-12-02 04:31:22 29 4
gpt4 key购买 nike

以下几行是我需要在 lua 中使用的任意正则表达式。

['\";=]
!^(?:(?:[a-z]{3,10}\s+(?:\w{3,7}?://[\w\-\./]*(?::\d+)?)?/[^?#]*(?:\?[^#\s]*)?(?:#[\S]*)?|connect (?:\d{1,3}\.){3}\d{1,3}\.?(?::\d+)?|options \*)\s+[\w\./]+|get /[^?#]*(?:\?[^#\s]*)?(?:#[\S]*)?)$
'(?i:(?:c(?:o(?:n(?:t(?:entsmartz|actbot/)|cealed defense|veracrawler)|mpatible(?: ;(?: msie|\.)|-)|py(?:rightcheck|guard)|re-project/1.0)|h(?:ina(?: local browse 2\.|claw)|e(?:rrypicker|esebot))|rescent internet toolpak)|w(?:e(?:b(?: (?:downloader|by mail)|(?:(?:altb|ro)o|bandi)t|emailextract?|vulnscan|mole)|lls search ii|p Search 00)|i(?:ndows(?:-update-agent| xp 5)|se(?:nut)?bot)|ordpress(?: hash grabber|\/4\.01)|3mir)|m(?:o(?:r(?:feus fucking scanner|zilla)|zilla\/3\.mozilla\/2\.01$|siac 1.)|i(?:crosoft (?:internet explorer\/5\.0$|url control)|ssigua)|ailto:craftbot\@yahoo\.com|urzillo compatible)|p(?:ro(?:gram shareware 1\.0\.|duction bot|webwalker)|a(?:nscient\.com|ckrat)|oe-component-client|s(?:ycheclone|urf)|leasecrawl\/1\.|cbrowser|e 1\.4|mafind)|e(?:mail(?:(?:collec|harves|magne)t|(?: extracto|reape)r|(siphon|spider)|siphon|wolf)|(?:collecto|irgrabbe)r|ducate search vxb|xtractorpro|o browse)|t(?:(?: ?h ?a ?t ?' ?s g ?o ?t ?t ?a ? h ?u ?r ?|his is an exploi|akeou)t|oata dragostea mea pentru diavola|ele(?:port pro|soft)|uring machine)|a(?:t(?:(?:omic_email_hunt|spid)er|tache|hens)|d(?:vanced email extractor|sarobot)|gdm79\@mail\.ru|miga-aweb\/3\.4|utoemailspider| href=)|^(?:(google|i?explorer?\.exe|(ms)?ie( [0-9.]+)?\ ?(compatible( browser)?)?)$|www\.weblogs\.com|(?:jakart|vi)a|microsoft url|user-Agent)|s(?:e(?:archbot admin@google.com|curity scan)|(?:tress tes|urveybo)t|\.t\.a\.l\.k\.e\.r\.|afexplorer tl|itesnagger|hai)|n(?:o(?:kia-waptoolkit.* googlebot.*googlebot| browser)|e(?:(?:wt activeX; win3|uralbot\/0\.)2|ssus)|ameofagent|ikto)|f(?:a(?:(?:ntombrows|stlwspid)er|xobot)|(?:ranklin locato|iddle)r|ull web bot|loodgate|oobar/)|i(?:n(?:ternet(?: (?:exploiter sux|ninja)|-exprorer)|dy library)|sc systems irc search 2\.1)|g(?:ameBoy, powered by nintendo|rub(?: crawler|-client)|ecko\/25)|(myie2|libwen-us|murzillo compatible|webaltbot|wisenutbot)|b(?:wh3_user_agent|utch__2\.1\.1|lack hole|ackdoor)|d(?:ig(?:imarc webreader|out4uagent)|ts agent)|(?:(script|sql) inject|$botname/$botvers)ion|(msie .+; .*windows xp|compatible \; msie)|h(?:l_ftien_spider|hjhj@yahoo|anzoweb)|(?:8484 boston projec|xmlrpc exploi)t|u(?:nder the rainbow 2\.|ser-agent:)|(sogou develop spider|sohu agent)|(?:(?:d|e)browse|demo bot)|zeus(?: .*webster pro)?|[a-z]surf[0-9][0-9]|v(?:adixbot|oideye)|larbin@unspecified|\bdatacha0s\b|kenjin spider|; widows|rsync|\\\r))'

还有很多其他的来源......正如您可能注意到的那样,第一种情况只有 "使用 \" 进行转义机器人不是 '因此,

rex_pcre.new('['\";=]')

不起作用。

rex_pcre.new("['\";=]")

但是,正则表达式中的部分应该可以工作,例如 \- .

我也无法使用

[[ ]]

因为存在以 ] 结尾的正则表达式(第一个例子)断行如

rex_pcre.new( [[
['\";=]
]])

在诸如第三个以 ) 结尾的情况下,对我不起作用并且还引发了意外符号的错误。

总之,我正在寻找这样的 r"UNESCAPED STRING" Python 或 @"UNESCAPED STRING" C# 的..

我认为没有这样的,但想知道如何获得类似的功能,因为事实上,我只使用这些值(正则表达式)并且无法控制如何最初组合它们..

这是我当前的解决方案我只是尝试用 [[ ]] 编译该行,如果失败,则移至"然后到“'”/

EscapeRegEx = function (xp)
-- try with [[ ]]
local opening = '[['
local closing = ']]'
local codeline = "rex_pcre.new(" .. opening .. xp .. closing .. ")"
_, err = loadstring(codeline)
if not err then return codeline end

-- then try with "
opening = '"'
closing = '"'
codeline = "rex_pcre.new(" .. opening .. xp .. closing .. ")"
_, err = loadstring(codeline)
if not err then return codeline end

-- then try with '
opening = "'"
closing = "'"
codeline = "rex_pcre.new(" .. opening .. xp .. closing .. ")"
_, err = loadstring(codeline)
if not err then return codeline end

end

最佳答案

您可以使用更长版本的长括号:

[=========[the regex goes in here]=========]

左长括号只能与相同长度的右长括号匹配。

参见this更多细节;您还可以执行类似的操作来获取嵌套的多行注释。

关于string - 有没有办法在lua(原始)中定义自动转义字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7944961/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com