samedi 24 août 2019

Street & Number formatting using RegEx: Switch order of various number formats (e.g 0-9 OR 0-9a-z OR 0-9-0-9a-z) followed by text

Would any RegEx wizard help me understanding how to cover different "variances"?

I got various formats of a street name with number, unfortunately all messed up and looking like this now

Messy State:

  • [0-9] Streetname (Example: 12 Street)
  • [0-9[a-z] Streetname (Example: 12b Street)
  • [0-9]-[0-9] Streetname (Example: 12-14 Street)
  • [0-9]-[0-9][a-z] Streetname (Example: 12-14b Street)

Desired State:

  • Streetname [0-9] (Example: Street 12)
  • Streetname 0-9[a-z] (Example: Street 12b)
  • Streetname [0-9]-[0-9] (Example: Street 12-14)
  • Streetname [0-9]-[0-9][a-z] (Example: Street 12-14b)

Background: Since google contacts somehow managed to mess up all my contacts addresses by showing the house-number first followed by the street I want to edit them in google sheets.

I´d love to "show-off" how great I did so far, but the truth is: I got no plan on how to cover all the different cases

Aucun commentaire:

Enregistrer un commentaire