none
"parse" a text file RRS feed

  • Question

  • How can "parse" a text file and modify the all mobile numbers with another format?
    +33 xxx xxx xxx  -> xxxxxxxxx

    In this file, exits more data: SamAccountName;givenName;sn;st;Department;mobile;mail

    Thanks!

    Sunday, July 17, 2016 5:15 PM

Answers

  • Just use replace:

    PS > '+33 xxx xxx xxx' -replace '\+33',''
     xxx xxx xxx
    PS > '+33 xxx xxx xxx' -replace ' ',''
    +33xxxxxxxxx


    \_(ツ)_/

    • Marked as answer by SysAdm.MAC Sunday, July 17, 2016 6:18 PM
    Sunday, July 17, 2016 5:51 PM

All replies

  • It is a CSV file.  Just use CSV to change the column.

    Import-Csv file.csv -delim ';'| %{$_.mobile}


    \_(ツ)_/

    Sunday, July 17, 2016 5:28 PM
  • But what I need is to remove the prefix and namespaces to mobile
    Sunday, July 17, 2016 5:35 PM
  • Just use replace:

    PS > '+33 xxx xxx xxx' -replace '\+33',''
     xxx xxx xxx
    PS > '+33 xxx xxx xxx' -replace ' ',''
    +33xxxxxxxxx


    \_(ツ)_/

    • Marked as answer by SysAdm.MAC Sunday, July 17, 2016 6:18 PM
    Sunday, July 17, 2016 5:51 PM