Reputation: 184
I would like a write a regex in Java to filter strings like this: FROM: [email protected]
.
What I exactly want to filter looks like this:
["FROM" on beginning of the line] [undefinied number of white space character] [":" colon] [undefinied number of white space character] [any alphanumeric character plus any point(".") character) "] ["@" at] [any alphanumeric character plus any point(".") character) "] ["end of line character"]
I've already tried this: ^FROM\\s*:\\s*\\.*@\\.*
, but it doesn't work. (I used double slashes because I wanna pass it to a Pattern like string.)
Upvotes: 1
Views: 91
Reputation: 89584
You have forgotten alphanumeric characters:
^FROM\s*:\s*[a-zA-Z0-9.]+@[a-zA-Z0-9.]+
Upvotes: 4