Ok, my previous questions were answered ... I have one more, this one is more difficult for me...
好的,我之前的问题得到了解答......我还有一个问题,这个对我来说更难...
^([A-Za-z]+\.[A-Za-z0-9_-]+\.domain\.com)$
Right now this expression produces only 1 capture group as noted with ^() ; How would I do 2 capture groups for this URL? (for IIS regular expression rewrite)
此时此表达式仅生成1个捕获组,如^()所示;如何为此URL执行2个捕获组? (用于IIS正则表达式重写)
1 个解决方案
#1
3
You can do this by enclosing the relevant portions like so:
您可以通过包含相关部分来完成此操作:
text = "city.state.domain.com"
pattern = "^([^\.]+).([^\.]+).([^\.]+).([^\.]+)$"
match = re.match(pattern, text)
match.groups()
# Returns: [ 'city', 'state', 'domain', 'com' ]
#1
3
You can do this by enclosing the relevant portions like so:
您可以通过包含相关部分来完成此操作:
text = "city.state.domain.com"
pattern = "^([^\.]+).([^\.]+).([^\.]+).([^\.]+)$"
match = re.match(pattern, text)
match.groups()
# Returns: [ 'city', 'state', 'domain', 'com' ]