none
Digits Only Regular Expression - RegexClean Transformation RRS feed

  • Question

  • I have a list of international and mis-typed phone numbers to data scrub.  They contain all sorts of symbols and formatting.  E.g., ...

    5511-4588-1705
    81.2.726.7782
    63-7-3266-0677

    I'm trying to write a regular expression using the free Konesans RegexClean SSIS transformation to take a string, identify only digits, and replace the string with a digits-only version.  I'm having difficulty figuring out the correct syntax because I never know how many digits, digit groupings, or symbols each string will have.  Is this possible using a regular expression and RegexClean?

    • Edited by Devin Howe Thursday, April 23, 2009 11:51 PM
    Thursday, April 23, 2009 11:47 PM

Answers

  • It's pretty ugly, but this seems to work.  Just add more variables to the match and replace expressions if you have more than 7 segments of numbers in your string.

    Match Expression: \D*(?<a>\d+)\D*(?<b>\d+)\D*(?<c>\d+)\D*(?<d>\d+)\D*(?<e>\d+)\D*(?<f>\d+)\D*(?<g>\d+)

    Replace Expression: ${a}${b}${c}${d}${e}${f}${g}
    Friday, April 24, 2009 4:46 PM