简体   繁体   中英

How can i blacklist words in a regular expression?

I am trying to blacklist the words "unknown" and "reboot". How do i do that using regular expressions?

And i have a list of users that it matches but i want it to blacklist certain words like unknown and reboot whilst still matching names such as "15ppool" and "vici".

This is what my current expression looks like that i have tried:

 ^[a-z]+|\w{4,8}

Unless you have to build a regex to match your desired format, just exclude those two terms:

while(<DATA>){
    chomp;
    say unless /unknown|reboot/;
}

__DATA__
foo
15ppool
unknown
bar
vici
reboot
baz

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