Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can some one explain me the this regex pattern in python? re.findall("[a-zA-Z*,*\-!*.]"

re.findall("[a-zA-Z*,*\-!*.]"

This regular expression checks for valid letters, ".", "-", "-", "!" in a word.
I understood the first part

[a-zA-Z]

Can someone please explain this?

[*,*\-!*.]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use the online tool regex101 to understand your regex and test it, for example, here is the explanation for this regex:

Match a single character present in the list below [a-zA-Z*,*\-!*.]
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
*,* matches a single character in the list *, (case sensitive)
* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
!*. matches a single character in the list !*. (case sensitive)
! matches the character ! with index 3310 (2116 or 418) literally (case sensitive)
* matches the character * with index 4210 (2A16 or 528) literally (case sensitive)
. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading