简体   繁体   中英

RegEx works in regexr but not in python re

I have this regex: Sie haben sich mit folgender E-Mail-Adresse[a-zA-Z0-9öäüÖÄÜ<>\n\-=#;&?_ "/:.@]+Abmeldung<\/a> . It works on regexr but not when I am using the re library in Python:

data = "<my text (comes from a file)>"
search = "Sie haben sich mit folgender E-Mail-Adresse[a-zA-Z0-9öäüÖÄÜ<>\n\\-=#;&?_ \"/:.@]+Abmeldung<\/a>"
print(re.search(search, data))

Is there something I don't see?

Thank you!

the pattern you are using on regexr contains \- but in your exemple shows \\- wich may give an incorrect regex. (and add the r in front of of the string as jupiterby said).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM