include::description.adoc[]

== Noncompliant Code Example

[source,python]
----
import re

def foo():
    pattern = re.compile(r"(?P<a>.)")
    matches = pattern.match("abc")
    g1 = matches.group("b") # Noncompliant - group "b" is not defined
    g2 = matches.group(1) # Noncompliant - Directly use 'a' instead of its group number.
----


== Compliant Solution

[source,python]
----
import re

def foo():
    pattern = re.compile(r"(?P<a>.)")
    matches = pattern.match("abc")
    g = matches.group("a")
----

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

include::message.adoc[]

include::highlighting.adoc[]

endif::env-github,rspecator-view[]
