GSuite Filling the G-Apps: Forms, Contact Numbers and Regular Expressions

GSuite Forms added their regular expression functionality a while ago but finding the correct combination for your scenario online can be cumbersome if you're not heavily into a language that makes use of regular expressions in it' entirety and Google doesn't seem to provide relevant samples probably because the combinations can be vast and "why don't you just Google it?".

Below are some details I found useful for enforcing correct number formatting when entering details in some Google Forms I've had to create:


I found "The Cheat Sheet - Javascript regular expressions" useful in resolving some of these:

BSB

^\d{3}-\d{3}?$
This uses a strict (3-3) format i.e. ###-###

TFN

Australian Tax File Numbers are  9 digits in the format of (3-3-3)
^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{3}|(\([0-9]{3}\)|[0-9]{3} )[0-9]{3} [0-9]{3}|(\([0-9]{3}\)|[0-9]{3})[0-9]{3}[0-9]{3}$

ABN

Australian Business Numbers can have a number of variations so this isn't a foolproof solution but should  generally work for an 11 digit combination with varying spacing combinations or none at all
^(\d *?){11}$

Mobile

^(\([0-9]{3}\)|[0-9]{4}-)[0-9]{3}-[0-9]{3}|(\([0-9]{3}\)|[0-9]{4} )[0-9]{3} [0-9]{3}|(\([0-9]{3}\)|[0-9]{4})[0-9]{3}[0-9]{3}$
Using (4-3-3) with either spaces or dashes i.e. #### ### ### or ####-###-###
^(?:\+?61|0)4 ?(?:(?:[01] ?[0-9]|2 ?[0-57-9]|3 ?[1-9]|4 ?[7-9]|5 ?[018]) ?[0-9]|3 ?0 ?[0-5])(?: ?[0-9]){5}$
As above but including +61 and limiting to current carrier prefixes

Australian Landline or Mobile (Including Area Code)

^\(?(?:\+?61|0)(?:(?:2\)?[ -]?(?:3[ -]?[38]|[46-9][ -]?[0-9]|5[ -]?[0-35-9])|3\)?(?:4[ -]?[0-57-9]|[57-9][ -]?[0-9]|6[ -]?[1-67])|7\)?[ -]?(?:[2-4][ -]?[0-9]|5[ -]?[2-7]|7[ -]?6)|8\)?[ -]?(?:5[ -]?[1-4]|6[ -]?[0-8]|[7-9][ -]?[0-9]))(?:[ -]?[0-9]){6}|4\)?[ -]?(?:(?:[01][ -]?[0-9]|2[ -]?[0-57-9]|3[ -]?[1-9]|4[ -]?[7-9]|5[ -]?[018])[ -]?[0-9]|3[ -]?0[ -]?[0-5])(?:[ -]?[0-9]){5})$
Please enter a mobile or landline (area code required) in any of the following formats:
  • ## #### ####
  • ## ####-####
  • ##########
  • (##)########
  • (##) #### ####
  • +61# #### ####
  • +61 # #### ####
  • +61#########
  • #### ### ###
  • ####-###-###

Comments

Popular posts from this blog

Excel Random Row Heights

Filling the G-Apps: RIP Google Legacy

Filling the G-Apps: Adding/Embedding LucidChart in Google Sites