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
+36.1k Golang : Display float in 2 decimal points and rounding up or down
+7.9k Golang : Emulate NumPy way of creating matrix example
+10.5k Golang : Removes punctuation or defined delimiter from the user's input
+30.4k Golang : Download file example
+9.8k Golang : Bcrypting password
+7.9k Golang : Qt splash screen with delay example
+16.2k Golang : File path independent of Operating System
+5.5k Golang : Error handling methods
+8.2k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+8.9k Golang : How to control fmt or log print format?
+11.2k Golang : Fuzzy string search or approximate string matching example
+5.5k Unix/Linux : How to test user agents blocked successfully ?