Regular expression – regular expression does not work in Go

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 = 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]$`

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>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5453 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.