Python re.search() Method
The re.search() method searches for a pattern anywhere
in the string.
Unlike match(), it doesn't require the pattern to be at the
beginning.
Syntax
re.search(pattern, string, flags=0)
Parameters
| Parameter | Description |
|---|---|
pattern |
Required. The regular expression pattern. |
string |
Required. The string to search. |
flags |
Optional. Matching flags. |
Return Value
A match object if found, otherwise None.
Example
Output
Click Run to execute your code
Enjoying these tutorials?