Golang : unknown escape sequence error
Encountered a funky error message unknown escape sequence while working this the tutorial on how to find IP address from a string. Apparently, Go doesn't like this statement :
regexPattern := numBlock + "\." + numBlock + "\." + numBlock + "\." + numBlock
and to fix the error, I've to escape the backslash.
regexPattern := numBlock + "\\." + numBlock + "\\." + numBlock + "\\." + numBlock
alternatively, backtick ` can be used to fix the error as well.
regexPattern := numBlock + `\.` + numBlock + `\.` + numBlock + `\.` + numBlock
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
+19.7k Golang : Measure http.Get() execution time
+19.6k Golang : Archive directory with tar and gzip
+19.5k Golang : Close channel after ticker stopped example
+5.2k Python : Convert(cast) string to bytes example
+18.9k Golang : Display list of time zones with GMT
+10.6k Golang : Flip coin example
+6.8k Mac/Linux/Windows : Get CPU information from command line
+6.8k Default cipher that OpenSSL used to encrypt a PEM file
+16.3k Golang :Trim white spaces from a string
+10.5k Golang : Resolve domain name to IP4 and IP6 addresses.