title: Google app Script phone number reformat
body: <p>I have a call log DB in google spreadsheets that is generated by a IFTTT Applet.
  This DB is then sent to a private web API by means of GAS with url.fetch commands(if your interested you can find a <a href="https://stackoverflow.com/questions/43322325/trying-to-post-data-from-google-spreadsheet-to-a-external-api">Post Here</a> with the code). For relevance. Using a onChange trigger for automation, I'm reformatting the data and then fetching the lastROW to API every time a new Row is inserted by IFTTT. </p>
  
  <p>It's working, but i have a problem with the phone number format. The format I'm getting from IFTTT is not consistent, for example ~80% of phone numbers have a format like this "40727000000"(11 digits no.) or "727000000"(9 digits no.), rest of them are international phone no. or robot phone no. formatted like this "393280000000" (12 digits no.) or less then 9 digits no. for robot.
  Now the format I send to API needs to be a 10 digits no. like 0727000000 (but only for those ~80% of numbers, the international and robot numbers need's to remain the same).</p>
  
  <p>So in essence i need to write a function in GAS with 3 scenarios: </p>
  
  <ol>
  <li><p>If it has 12 digits or less then 9 digits, do nothing.</p></li>
  <li><p>If it has 11 digits delete the first digit, in my case is always "4".</p></li>
  <li><p>If it has 9 digits add a "0" in front of "7", it's always "7".  </p></li>
  </ol>
  
  <p>Thank you!   </p>