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
+4.6k Unix/Linux/MacOSx : Get local IP address
+11k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+39.7k Golang : How to check if a string contains another sub-string?
+5k Golang : Calculate US Dollar Index (DXY)
+9.9k Android Studio : Create custom icons for your application example
+14.3k Golang : How to convert(cast) IP address to string?
+14.8k Golang : Get sub string example
+6.2k Golang : Example of custom handler for Gorilla's Path usage.
+38.1k Golang : UDP client server read write example
+18.7k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+11.2k Golang : Extract part of string with regular expression
+6.3k Golang : How to stop user from directly running an executable file?