title: I need a regular expression to remove white space in the beginning and it should allow spaces in between two words
body: <p>Here is my source code. I have written a directive in angularjs to eliminate spaces. It's perfectly working for spaces between words but is still allowing spaces at the beginning.</p>
  
  <pre><code>function customValidation() {
  
     return {
       require: 'ngModel',
       link: function(scope, element, attrs, modelCtrl) {
  
         modelCtrl.$parsers.push(function (inputValue) {
  
           var transformedInput = inputValue.toLowerCase().replace(/ /g,''); 
  
           if (transformedInput!== inputValue) {
             modelCtrl.$setViewValue(transformedInput);
             modelCtrl.$render();
           }         
  
           return transformedInput;         
         });
       }
     };
  }
  </code></pre>