dimanche 24 novembre 2019

Escaping meta-characters when searching for them in a string?

I was wondering, when trying to do a search for the . , i tried this:

'\.' , using a back slash to escape the meta-character

however when I tried to see if it would find it on this string:

My Silly Cat ate my hamster. Oh well too bad.

my code simply returns False!

however when I tried this:

'\\.' , the code searched the string and returned TRUE!

how and why does it return true when I double backslash the . ?

Aucun commentaire:

Enregistrer un commentaire