在Golang中如何“匹配相同编号的组的内容”?

We can use umber to "Matches the contents of the group of the same number" in Python. See Python re doc.

For example:

There are two strings:var abc=123; abc=234; and var abc=123; xyz=234;. I want to capture the first one but not the second.

We can use var\s+(\w+)\s*=\s*\d+\s*;\s*\1\s*=\s*\d+\s*; to do this in Python.

Now the question is how to do this in Golang?

Go does not support backrefernces (like \1). You can bypass that by using two-step match (first find a pattern and the check that it appears twice) or by changing regexp engine.

See also this question