需求1: (命名分组)
2001-02-03
Python:
\d\d(?P<year>\d\d)-(?P<month>\d\d)-(?P<day>\d\d)
Tcl:
regexp -linestop {\d\d(\d\d)-(\d\d)-(\d\d)} $subject sTmp year month day
需求2:(命名分组和前向引用)
2008-08-08
Python:
\d\d(?P<magic>\d\d)-(?P=magic)-(?P=magic)
原文链接:https://www.f2er.com/regex/361869.html