|
本帖最后由 ThxAlot 于 2021-7-19 18:37 编辑
REGEX可以通过Web.Page()函数在PQ里直接使用,即间接通过js使用regex,这样就可以使用assertion lookbehind了。
===============================
有幺蛾子了
js本身是支持lookbehind的,但是嵌入到Web.Page()里的js似乎又不行了。。。
搜了半天也找不到个权威的说法,还请各位大神帮忙留意下,谢谢!
PS: 附件的网页回显是正确的,但是相同的js在PQ里就报错,只能改用non-capturing了
- let
- RE = (regex as text, str as text) => Web.Page("<script>var regex = " & regex & "; var str = """ & str & """; var res = regex.exec(str)[1]; document.write(res)</script>")[Data]{0}[Children]{0}[Children]{1}[Text]{0},
- Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nVPbTgMhEP0Xn6W7bG2a+OYH+AVNH6YwZYnAIJe4NXy8tF1tomlJfSFkOJcZcmazeQCj0X1AwIVEY9gugJMLQbZ7WfHXoR/67mH7eAMGOVCAwIcGbn8Y+p4vW3KWryxfX3yFK59jkWMswtWTl4gQxMjyNN8CxmxSLAl2xQeSWaQrxORLHMkXMWoHphpqpzwoLD/NMIlg/s+u9pbupauIQWNkCmwt3cs+WSZNrkE8DhaLJ58NBGbAJ/KnaWODiFl8f6vEBLqqXAae+JoFPss1hEayWLSTODWAs5uAhIrCodoZNtdinSO+Va9W1zc1zu3+lUDveTE1VK6GS5LIFl0qAqwHrVxFkGMRzZ69OziRx5R8fO665m7MWW7iz+EPT2c4SfUbcNyLyUe+vIpQVJ+2Xw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [URL = _t]),
- #"Added Custom" = Table.AddColumn(Source, "Custom", each RE("/(?:ux\||shop\||.com\/)(.+)/gi", [URL]))
- in
- #"Added Custom"
复制代码
|
评分
-
1
查看全部评分
-
|