While sending internal message on a system people usally share there phone number and making call outside the system which divert traffic from our system. So while exchanging messages within system we need to hide the phone number. This can be achieved in ruby by making use of regex:
phone_format_one = '5125551234'
phone_format_two = '512.555.1234'
phone_format_three = '512-555-1234'
regex = /(\d{3,4}[.-]{0,1}){3}/
string_to_match = 'Can we talk over
512.555.1234' string_to_match.gsub(/(\d{3,4}[.-]{0,1}){3}/,'(Phone
number hidden)')
Would result in : Can we talk over (Phone number hidden)
Thus effectively hidding phonenumber from user.
0 Comment(s)