Fuxi
Fuxi

Reputation: 7589

Regex Question (detecting spam)

I'm getting strange kind of spam, where the email body only contains this:

4606142 5801100 2704743

How can I grep this with regex?

It's 3x7 numbers, separated with space.

thx

Upvotes: 0

Views: 189

Answers (4)

Rubens Farias
Rubens Farias

Reputation: 57936

Try this

(\d{7} ?){3}

or, if that whitespace makes a difference (just like Al said in comments)

(\d{7} ){2}\d{7}

Upvotes: 4

t0mm13b
t0mm13b

Reputation: 34592

Would this do? (\d{1,7}\s{0,})+

The reason I conclude the \s with a quantifier is it will fail when it reaches the end of the line where the last character after that may not be a space but a carriage return.

Hope this helps, Best regards, Tom.

Upvotes: 0

soulmerge
soulmerge

Reputation: 75704

You might want to capture arbitrary combinations of digits and whitespace:

^[\d\s]*$

Upvotes: 0

spa
spa

Reputation: 5185

Try this

[0-9]{7}\s[0-9]{7}\s[0-9]{7}

[0-9]{7}: 7 occurences of the characters '0' to '9'

\s: whitespace character

Upvotes: 0

Related Questions