re2

Apps Script Regex - Case Insensitive

*爱你&永不变心* 提交于 2020-01-13 19:11:13
问题 I am writing an apps script for Google Docs. I am using findText() to locate an instance of a specified string of characters. By default, it is case sensitive and I need to remove that, but I can't figure out how to add the /i to the re2 regex so that it works in apps script engine. In my example, I am trying for find all instances of micssys (e.g. micssys, Micssys, MICSSYS, etc). Right now I have: var text = "micssys"; var bodyElement = DocumentApp.getActiveDocument().getBody(); var

go爬虫:正则表达式及第三方库

不想你离开。 提交于 2020-01-09 22:24:57
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 一、正则表达式抓取 //比如找到所有的a链接 //注意匹配模式在最前面的 (?m),加了多行匹配模式后,点号不能匹配换行符 pattern := `(?msU)<a.*href="(.*)".*>(.*)</a>` reg = regexp.MustCompile(pattern) match := reg.FindAllStringSubmatch(html, -1) //FindAllStringSubmatch会将捕获到的放到子slice if match != nil { fmt.Print("%#v", match) } go正则: http://studygolang.com/static/pkgdoc/pkg/regexp.htm 具体参考: https://github.com/google/re2/wiki/Syntax 这里可以看到很多字符含义: [[:alnum:]] alphanumeric (≡ [0-9A-Za-z] ) [[:alpha:]] alphabetic (≡ [A-Za-z] ) [[:ascii:]] ASCII (≡ [\x00-\x7F] ) [[:blank:]] blank (≡ [\t ] ) [[:cntrl:]] control (≡ [\x00-

Using REGEXEXTRACT in an array, searching multiple columns

爱⌒轻易说出口 提交于 2020-01-05 04:57:16
问题 Can someone please tell me what I am doing wrong in this formula? =ARRAYFORMULA(REGEXEXTRACT((A2:A&"")+(B2:B&"")+(C2:C&"")), "02(\d{14})37") I'm trying to extract a 14 digit number that sits between 02 and 37 that may be in columnA, columnB or columnC. I've tried this also, with the expected result showing on the first row only: =ARRAYFORMULA(REGEXEXTRACT(textjoin(" ",true,A2:C),"02(\d{6,14})37")) I'm really confuzzled. 回答1: it needs to be like this: =ARRAYFORMULA(IFERROR(IFERROR(IFERROR

Google RE2 Regex Escaping periods and underscores error

邮差的信 提交于 2019-12-12 19:02:42
问题 I'm trying to validate a username string with the following characteristics: Not start with a . or _ Not end with a . Don't allow two . in a row Only lowercase letter characters and numbers my code is username.matches('^(?!\.)(?!_)(?!.*\.$)(?!.*?\.\.)[a-z0-9_.]+$') Using a regex simulator online it's working https://regex101.com/r/bDXMg3/2/ But using the same syntax in Google RE2 Syntax (used in Firestore Security Rules) is throwing a ton of errors I tried to then double escape each . using

Error: Failed to parse regular expression “”: pattern too large - compile failed

旧时模样 提交于 2019-12-11 10:24:14
问题 I find the following phenomena: I have a BQ query with 100s of fields extracted using REGEXP_EXTRACT function. I added a new expression and got the following Error: Failed to parse regular expression "": pattern too large - compile failed. When querying this expression alone, everything runs fine, in a larger query, i get the error. This is a replica of the problem base on the github sample data and a simple regex: SELECT repository.description, REGEXP_EXTRACT(repository.description,r'(?:\w)

Is it possible to use re2 from Python?

末鹿安然 提交于 2019-12-09 05:07:26
问题 i just discovered http://code.google.com/p/re2, a promising library that uses a long-neglected way (Thompson NFA) to implement a regular expression engine that can be orders of magnitudes faster than the available engines of awk, Perl, or Python. so i downloaded the code and did the usual sudo make install thing. however, that action had seemingly done little more than adding /usr/local/include/re2/re2.h to my system. there seemed to be some ``` .a file in addition, but then what is it with

apps script findText for docs

不问归期 提交于 2019-12-07 22:53:44
问题 I know that the findText function for Google Doc elements doesn't use regular regex (it uses RE2, instead). I'm coming up against a regex issue where a validated, relatively simple, and seemingly supported regex block is paradoxically returning a null result in Apps Scripts. Wondering if anyone can spot/explain the reason. Thanks! I'm applying the code below to a block of text with some markdown code block ticks (```). The RegEx returns correct results when I paste the regex shown below into

apps script findText for docs

无人久伴 提交于 2019-12-06 04:32:06
I know that the findText function for Google Doc elements doesn't use regular regex (it uses RE2 , instead). I'm coming up against a regex issue where a validated, relatively simple, and seemingly supported regex block is paradoxically returning a null result in Apps Scripts. Wondering if anyone can spot/explain the reason. Thanks! I'm applying the code below to a block of text with some markdown code block ticks (```). The RegEx returns correct results when I paste the regex shown below into regexer.com with a similar code block. However, running the code below on my doc is returning a null

Apps Script Regex - Case Insensitive

自闭症网瘾萝莉.ら 提交于 2019-12-06 04:17:27
I am writing an apps script for Google Docs. I am using findText() to locate an instance of a specified string of characters. By default, it is case sensitive and I need to remove that, but I can't figure out how to add the /i to the re2 regex so that it works in apps script engine. In my example, I am trying for find all instances of micssys (e.g. micssys, Micssys, MICSSYS, etc). Right now I have: var text = "micssys"; var bodyElement = DocumentApp.getActiveDocument().getBody(); var searchResult = bodyElement.findText(text); I have tried: var searchResult = bodyElement.findText("/"+text+"/i")

How can I normalize / asciify Unicode characters in Google Sheets?

为君一笑 提交于 2019-12-04 12:07:40
问题 I'm trying to write a formula for Google Sheets which will convert Unicode characters with diacritics to their plain ASCII equivalents. I see that Google uses RE2 in its "REGEXREPLACE" function. And I see that RE2 offers Unicode character classes. I tried to write a formula (similar to this one): REGEXREPLACE("público","(\pL)\pM*","$1") But Sheets produces the following error: Function REGEXREPLACE parameter 2 value "\pL" is not a valid regular expression. I suppose I could write a formula