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
+11.3k Get form post value in Go
+5.4k Linux : Disable and enable IPv4 forwarding
+9.1k Golang : Changing a RGBA image number of channels with OpenCV
+20.4k Golang : How to force compile or remove object files first before rebuild?
+9.6k Golang : Translate language with language package example
+36.7k Upload multiple files with Go
+20k Golang : Pipe output from one os.Exec(shell command) to another command
+31.5k Golang : Validate email address with regular expression
+4k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+14k Golang : Reset buffer example
+10.9k Golang : Characters limiter example
+5.2k PHP : Fix Call to undefined function curl_init() error