I see this line of code and the regular expression just panics me…
quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/
Can someone please explain little by little what it does?
Thanks,G
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.
Here’s what I can extract:
^beginning of string.(?:non-matching group.[^#<]*any number of consecutive characters that aren’t#or<.(<[\w\W]+>)a group that matches strings like<anything_goes_here>.[^>]*any number of characters in sequence that aren’t a>.The part after the
|denotes a second regex to try if the first one fails. That one is#([\w\-]*):#matches the#character. Not that complex.([\w\-]*)is a group that matches any number of word characters or dashes. BasicallyThings-of-this-form$marks the end of the regex.I’m no regex pro, so please correct me if I am wrong.