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.1k Golang : On enumeration
+27.9k Golang : Get time.Duration in year, month, week or day
+22.7k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+6.2k Golang : How to handle file size larger than available memory panic issue
+20.7k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+11.2k Golang : How to display image file or expose CSS, JS files from localhost?
+17.8k Golang : Check if directory exist and create if does not exist
+15.3k CodeIgniter/PHP : Create directory if does not exist example
+5k Golang : Extract XML attribute data with attr field tag example
+13.8k Golang : Get timezone offset from date or timestamp
+7.3k Golang : Convert word to its plural form example
+4.4k Golang : Intercept, inject and replay HTTP traffics from web server