Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to catch phone number in string

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 221
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: