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.3k Android Studio : Import third-party library or package into Gradle Scripts
+9.8k Golang : Channels and buffered channels examples
+17k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+5.5k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+12k Golang : Display list of countries and ISO codes
+34.2k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+9.9k Golang : Compare files modify date example
+13k Golang : Date and Time formatting
+15.9k Golang : How to extract links from web page ?
+4.5k MariaDB/MySQL : Form select statement or search query with Chinese characters
+16.1k Golang :Trim white spaces from a string
+7.3k Golang : Shuffle strings array