0
 public addressPattern: string = "^([^\s]*[A-Za-z0-9][\s]{0,1})*$";

this is how i written but it allowing the space in the begining and ending also.which i need to show error at that time.

Naga Sai A
  • 10,771
  • 1
  • 21
  • 40
ajay
  • 129
  • 2
  • 17
  • Try removing the quotes and replacing them with forward slashes, ex. `public addressPattern = /^([^\s]*[A-Za-z0-9][\s]{0,1})*$/;` – Chris Nov 18 '19 at 15:45
  • Does this answer your question? [RegEx for no whitespace at the beginning and end](https://stackoverflow.com/questions/34974942/regex-for-no-whitespace-at-the-beginning-and-end) – alphapilgrim Nov 18 '19 at 15:49
  • the data type is string so need to give the double quotes – ajay Nov 18 '19 at 16:00
  • Exactly the same thing but its not working which i uses from thehttps://stackoverflow.com/questions/34974942/regex-for-no-whitespace-at-the-beginning-and-end – ajay Nov 18 '19 at 16:28
  • im still working on it "^([^\s]*[A-Za-z0-9][\s]{0,1}[^\s])*$";if i keep like this ,it takes whitespace in the begining and in the end also – ajay Nov 18 '19 at 17:04
  • Can you show us how you're calling this, and an example of a string that passes that you want to fail? – Harry Vane Nov 18 '19 at 19:29

0 Answers0