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
+8.8k Golang : GMail API create and send draft with simple upload attachment example
+4.9k Swift : Convert (cast) Float to Int or Int32 value
+11.8k Golang : Setup API server or gateway with Caddy and http.ListenAndServe() function example
+12.4k Golang : Exit, terminating or aborting a program
+14.3k Golang : How to determine if user agent is a mobile device example
+6.7k Golang : Get expvar(export variables) to work with multiplexer
+8.4k Linux/Unix : fatal: the Postfix mail system is already running
+4.8k JQuery : Calling a function inside Jquery(document) block
+6.9k Golang : Gargish-English language translator
+17.7k Golang : Qt image viewer example
+15.4k Golang : Force download file example
+7.7k Golang : Regular Expression find string example