[python]Match all once or none

. is a wildcard which occurs once.
* is zero or more times, will also return more than one character between foo and bar.
+ is one or more times, will return also more than one character that is between foo and bar.
the pattern “foo.bar” will present any single character between foo and bar.
the pattern “foo.*bar” will return also the string that has no character in between foo and bar

Pattern “foo.bar
['fooabar', 'fooxbar', 'foocbar']

Pattern “foo.*bar
['fooabar', 'fooxbar', 'foobar', 'fooxybar', 'foocbar']

Pattern “foo.+bar
['fooabar', 'fooxbar', 'fooxybar', 'foocbar']

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s