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
+13.4k Golang : How to get year, month and day?
+31.5k Golang : Get local IP and MAC address
+28.5k Get file path of temporary file in Go
+36.2k Golang : How to split or chunking a file to smaller pieces?
+5.4k Golang *File points to a file or directory ?
+17k Golang : Covert map/slice/array to JSON or XML format
+21.8k Golang : Convert string slice to struct and access with reflect example
+19.8k Golang : Measure http.Get() execution time
+6.2k Golang & Javascript : How to save cropped image to file on server
+18.5k Golang : Generate thumbnails from images
+17.6k Golang : Read data from config file and assign to variables
+14.5k Golang : Overwrite previous output with count down timer