[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']

Advertisement

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 )

Facebook photo

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

Connecting to %s