Golang : error parsing regexp: invalid or unsupported Perl syntax
Compiling and running Golang program will throw out some odd error messages sometimes. Got one today with this error message below while testing out regular expressions in Golang :
error parsing regexp: invalid or unsupported Perl syntax: (?!
Apparently it was because Perl syntax and negative lookahead is not supported in Golang. Golang's Regular Expression syntax is different from PCRE's (which is used by php and javascript ).
To fix this you can either convert your regular expression to non-Perl syntax style or install https://github.com/tuxychandru/golang-pkg-pcre/
If you requirement is not too complex, you can also consider the Golang unicode
package. There are couple of functions such as IsDigit, IsNumber and IsPunct that might be useful.
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+8.9k Golang : Get escape characters \u form from unicode characters
+6.2k Golang : Calculate how many weeks left to go in a given year
+5.9k Golang : Transform lisp or spinal case to Pascal case example
+13.4k Golang : Find commonalities in two slices or arrays example
+10.3k Golang : Concurrency and goroutine example
+9.2k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine
+17.2k Golang : Example for RSA package functions
+18.2k Golang : How to Set or Add Header http.ResponseWriter?
+10.2k Golang : flag provided but not defined error
+21.6k Golang : Gorilla mux routing example
+15.2k Golang : Send email and SMTP configuration example
+5.7k Golang : Reverse by word