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?
[*,*\-!*.]
>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)