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
+14k Golang : Get current time
+10.7k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+10.3k Golang : Random Rune generator
+16.6k Golang : Get IP addresses of a domain name
+10k Golang : Function wrapper that takes arguments and return result example
+8.8k Golang : Random integer with rand.Seed() within a given range
+5.7k Python : Print unicode escape characters and string
+6.7k Golang : Warp text string by number of characters or runes example
+4.7k Javascript : Detect when console is activated and do something about it
+10.6k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine
+6.3k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+15.3k Golang : Save(pipe) HTTP response into a file