How can I make sure that the string “To:” is at the beginning of the line and not at the middle or end?
This is what I have: result.match(/To\:(.*)/)[1].replace(/^\s+/, '');
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.
You want the
^anchor, i.e./^.../Keep in mind that this matches the start-of-string, which is fine if you read line by line. In case you have multiple lines (i.e. newlines) in your string and you want to allow matches on any such line, use the
m(“multi-line”) modifier:/^.../m