Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Remove all non-numbers from a Social Security Number

Last post 06-29-2009, 4:01 PM by mash. 1 replies.
Sort Posts: Previous Next
  •  06-29-2009, 2:14 PM 54428

    Remove all non-numbers from a Social Security Number

    I want to remove all non-numeric characters from a Social Security Number.

    Input: 111-00-3333
    Result from regExp replace should be: 111003333

    The result I am actually getting (which is wrong) is: 11100-3333'

     The reg expression that I am using is:  \D

    I am getting the wrong result from the following function.
    Please let me know what I'm doing wrong if anyone can see:

    Calling function here (using Classic ASP):


    Function RegExpNumbersOnly(taxID)
    Set re = New RegExp

    With re
    .Pattern = "\D"
    .IgnoreCase = True
    .Global = True
    End With

    RegExpNumbersOnly = re.Replace(taxID, "")
    End Function

  •  06-29-2009, 4:01 PM 54430 in reply to 54428

    Re: Remove all non-numbers from a Social Security Number

    MyronCope:

    I want to remove all non-numeric characters from a Social Security Number.

    Input: 111-00-3333
    Result from regExp replace should be: 111003333

    The result I am actually getting (which is wrong) is: 11100-3333'

     The reg expression that I am using is:  \D

    I am getting the wrong result from the following function.
    Please let me know what I'm doing wrong if anyone can see:

    Calling function here (using Classic ASP):


    Function RegExpNumbersOnly(taxID)
    Set re = New RegExp

    With re
    .Pattern = "\D"
    .IgnoreCase = True
    .Global = True
    End With

    RegExpNumbersOnly = re.Replace(taxID, "")
    End Function

    Check your code for typos, what you have posted here should work as you wanted with VBScript.  The ignorecase setting is meaningless for this pattern but I don't see why that would keep it from working.


    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
View as RSS news feed in XML