# Python thing that doesn't work in Sage, works in pure Python

In `sage -python`

:

```
>>> import re
>>> ST = "foobarsws"
>>> matches = re.match("(?:foo)?(bar)?(sws)?",ST)
>>> matches.groups()
('bar', 'sws')
>>> matches.group(0)
'foobarsws'
>>> matches.group(1)
'bar'
>>> matches.group(2)
'sws'
```

In Sage:

```
sage: import re
sage: ST = "foobarsws"
sage: matches = re.match("(?:foo)?(bar)?(sws)?",ST)
sage: matches.groups()
('bar', 'sws')
sage: matches.group()
'foobarsws'
sage: matches.group(0)
IndexError: no such group
sage: matches.group(1)
IndexError: no such group
sage: matches.group(2)
IndexError: no such group
```

Any ideas?

This one has gotten me, too. It's very annoying.

See [here](http://www.sagemath.org/doc/faq/faq-usage.html#i-have-type-issues-using-scipy-cvxopt-or-numpy-from-sage).

@bk322 - right, if I'd gotten that error I would have thought of this, but it was the `IndexError` that made it so weird. Because of course this error naturally appears anyway when you've tried to access a nonexistent group (like `matches.group(3)` would be above, I guess)