I am trying to learn javascript
i have this code:
x=x.replace(/^\s+|\s+$/g,"");
can i have a description about /^\s+|\s+$/g,””
searching to replace what with what ?
Regards
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a regular expression. Basically
\smatches whitespac characters and replaces them with"".edit:
/ ... /marks the regex.^\s+Take 1or more whitespaces at the beginning of the string.\s+$Take 1 or more whitespaces at the end of the string./gDont stop at the first match, but find all matches – “global flag”