ruby - Extract and replace emails and phone number from string -


I need to hide the email and phone number in the string. I change the formatted email / number with a regex Easy, but what about other formats? Here's an example:

Input:

Email address like email@example.com or email at dot com should be replaced. Phone numbers like 347 323 4567 or tree four seven, three two three four five six seven < / Code> should also be changed.

Output:

Email address like (email is hidden) or (email hidden) should be replaced. Phone numbers like (phone hidden) or (phone hidden) < / Strong> should also be changed

Airbank's message service is really good at doing this:

It looks for the symbols @, "Whatever I do not know about DOT Com" , And with some sensitivity to the number of numbers to be separated from at least 7 digits (telephone number).

What would be the best way to do the same thing? Writing complex regexes? Using a Natural Language Resource Library?

This code will not be easy, and there may be unpleasant results for your users, then your Customer Support People

.

123-446-7890 can be a phone number, or this is x = 123-456- 7890 . Imagine how upset your user would be when they received x = (phone hidden) .

The email address is also a difficult problem because you can get the specification for the email address by reading, and always have one in it. Although most people try to validate an address using a pattern, but they can be ugly to detect them.

In either case, there are Regex patterns attempting to do this, but they all fail when they fail.

For me, it seems like a non-fictitious idea made by an unknown executive,

Write a filter that is all dirty words Removes.

that I once received (yes, okay.) Is it the only human desire to use all written and spoken languages ​​on Earth or to use such words?) Working around is easy, and for many people it will be a challenge to defeat.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -