Please forgive me for being an amateur of regular expressions, but I am really confused, why this is not a piece of code that does not work in Go
< p>
package main
import (
"fmt"
"regexp"
)
func main () {
var a string = "parameter=0xFF"
var regex string = "^.+=0x[AF][AF]$"
result,err := regexp.MatchString(regex, a)
fmt.Println(result, err)
}
// output: false
This seems to be normal in python Work
import re
p = re.compile(r"^.+=0x[AF][AF]$")
m = p.match("parameter=0xFF")
if m is not None:
print m.group()
// output: parameter= 0xFF
What I want to do is to match whether the input format is
Any help will be greatly appreciated
Have you tried using raw string literals (using back quotes instead of quotes)?
Like this:
Like this:
var regex string = `^.+=0x[AF][AF]$`
Please forgive me for being an amateur of regular expressions, but I am really confused, why this is not a piece of code that does not work in Go
package main
import (
"fmt"
"regexp"
)
func main() {
var a string = "parameter=0xFF"
var regex string = "^.+=0x[AF][AF]$"
result,err := regexp. MatchString(regex, a)
fmt.Println(result, err)
}
// output: false
This seems to work fine in python< /p>
import re
p = re.compile(r"^.+=0x[AF][AF]$")
m = p.match("parameter=0xFF")
if m is not None:
print m.group()
// output: parameter=0xFF< /pre>What I want to do is to match whether the input format is
= 0x [AF] [AF] Any help will be greatly appreciated
Have you tried using raw string literals (using back quotes instead of quotes)?
Like this:var regex string = `^.+=0x[AF][AF]$`p>