How do I remove the prefixed zeros, spaces and any special characters?

Hey All,

I have an Excel file with mobile numbers in a column named “Mobile”.

As you can see in the screenshot attached below, all three rows are in different format.

image

How do I remove the prefixed zeros, spaces and any special characters ?

Thanks.

@uio

Try this Linq:

dtExcelData = (From row In dtExcelData.AsEnumerable()
               Let mobileNumber = New String(row.Field(Of String)("Mobile")
                               .Where(Function(c) Char.IsDigit(c)).ToArray())
               Select dtExcelData.Clone().LoadDataRow({mobileNumber}, False)
              ).CopyToDataTable()

Cheers…!

HI,

How about the following expression?

image

CurrentRow("Mobile") = System.Text.RegularExpressions.Regex.Replace(CurrentRow("Mobile").ToString,"\D","").TrimStart("0"c)

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.