Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use re.match function in python

Shulou Source: shulou.com Published: 2022-06-03 17:36:02 10月02日 Update

This article mainly shows you "how to use the re.match function in python", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use the re.match function in python" this article.

1. Match the regular expression from the starting position of the string, and the re.match function starts from the starting position of the string.

2. If the match fails, None will be returned, and if the match succeeds, the matching string will be returned.

Pattern is the regular expression, string is the string to match, and flags is the flag bit.

The re.match function matches from the starting position of the string.

Example

Import rex=re.match ("[1-9]\ d *", "123abd") if x functions none: print (x.group ()) else: print ("none") y=re.match ("[1-9]\ d *", "c123ad") if yawns none: print (y.group ()) else: print ("none") # output result: 123none above is all the contents of the article "how to use re.match functions in python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Functions positions content characters strings articles beginnings rules expressions learning help success examples understandability more organization flags knowledge results editing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Huawei Docker MariaDB Apple