Java regex for removing all characters except a pattern
问题 I have a string including e-mail. There are probably extra characters before and / or after it. input examples: a1@b.com a2@b.com abcd efg x y z a3@b.com p q a4@b.com x z asd[x5@c.net]gh I want to remove the extra characters. Desired outputs: a1@b.com a2@b.com a3@b.com a4@b.com x5@c.net Valid characters are a-zA-Z0-9._ So there are probably invalid characters before and / or after e-mail. I tried this code to identify whether it is a correct email or not (this assumes that it is separated