[go-nuts] regarding regex package
There’s a pure Go (no cgo needed) regexp engine that supports lookahead and lookbehind here: https://github.com/dlclark/regexp2 However, and I say this as someone who maintains that regex library, use this type of regex with caution. I would highly recommend changing your code to use the native, RE2-based engine if you can. Runaway regex’s on certain inputs is a risk with backtracking and is frequently a bad trade off in production. If you need compatibility because you don’t control the patterns being used or are porting code with lots of existing patterns (which is why the library exists) then regexp2 is nice to have in your back pocket. -Doug -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d89d0c25-90ab-49a5-9281-f8db334b029c%40googlegroups.com.
Re: [go-nuts] regarding regex package
On Sat, Sep 14, 2019 at 12:40 AM Durga Someswararao G wrote: > > I tried to execute one regular expression with regex package. When I try to > compile I am getting unsupported Perl syntax. After reading regex syntax > conclusion is golang not supporting some combination regex patterns like > positive lookahed,negative lookahed etc. Is there any alternative or anyway > to handle this in golang. > > Regex Syntax: https://github.com/google/re2/wiki/Syntax > Sample Code: https://play.golang.org/p/SwODqNNJtBN Not supporting all of Perl's regexp features is an intentional decision. See the discussion at https://swtch.com/~rsc/regexp/regexp1.html. When I search for "golang pcre" I see several Go packages that support Perl regular expressions, mostly by calling out to a PCRE library written in C. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWb%3Dm%2BfkKxmg4zhfJmETmsNwc1GTc5PQ8EkOpq%2BoN_k0Q%40mail.gmail.com.
[go-nuts] regarding regex package
Hi, I tried to execute one regular expression with regex package. When I try to compile I am getting unsupported Perl syntax. After reading regex syntax conclusion is golang not supporting some combination regex patterns like positive lookahed,negative lookahed etc. Is there any alternative or anyway to handle this in golang. Regex Syntax: https://github.com/google/re2/wiki/Syntax Sample Code: https://play.golang.org/p/SwODqNNJtBN Thanks, Durga SomeswaraRao G. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/6d9e5da0-9b9c-4712-abb6-5eb7cc7aa0a2%40googlegroups.com.