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
+12.6k Golang : Forwarding a local port to a remote server example
+17.7k Golang : delete and modify XML file content
+26.9k Golang : Find files by extension
+16.5k Golang : Check if a string contains multiple sub-strings in []string?
+9.1k Golang : Get SPF and DMARC from email headers to fight spam
+11.7k Golang : Concurrency and goroutine example
+12.3k Golang : Simple client-server HMAC authentication without SSL example
+8.4k Golang : Convert word to its plural form example
+4.7k Chrome : How to block socketloop.com links in Google SERP?
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format
+21.1k Golang : For loop continue,break and range
+24.6k Golang : How to validate URL the right way