简体   繁体   中英

python regex for multiple words not matching

So I have a regex like this -

[\w\s.<>/]* is [boom|box|cat]+[\w\s<>/]+[fun|lame][\w\s<>./]*

but this matches

<something>things/something> is brah <HELLO>loc</HELLO> suburb.

why?

[...] is a character class, it will match any individual character between the brackets, ie your [boom|box|cat] is identical to [abcotx|] . You want (boom|box|cat) and (fun|lame) .

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