what does this regular expression in python mean (.+?)
Question: I saw this regular expression being used in a program - (.+?) But I don't
understand What does this mean. I know that, . is for any character except
newline \+ is for one or more characters ? is for zero or one character

But don't understand what this entire regex (.+?) convey.


Answer: The parenthesis mean a [_capturing
group_](https://docs.python.org/2/howto/regex.html#grouping). The `.+` would
match any character _1 or more times_. The `?` makes it work in a [_non-
greedy_](https://docs.python.org/2/howto/regex.html#greedy-versus-non-greedy)
fashion.

Study [Regular Expression How To](https://docs.python.org/2/howto/regex.html)
\- it covers all of the parts of this regular expression.

This expression alone does not make much sense, and is usually a part of an
expression, sample:

    
    
    >>> import re
    >>> s = "Hello, World!"
    >>> re.match(r"(.+?), World!", s).group(1)
    'Hello'
    

