I am trying to make my regex work across multiple lines and “m” didn’t seem to work either. So, my regex is working for 1st line and noT for the following lines.
Share
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 can skip the
matchpart and just do it all in one step:.matches any character, but it excludes newlines.[\s\S]matches any character including newlines.I changed your search regex to
\*([\s\S]*?)\*, which non-greedily matches the stuff between the asterisks.The replacement string is
<i>$1</i>.$1is replaced with the contents of the first capturing group, which is your text.Also, because it looks like you’re trying to convert Markdown to HTML, try using a pre-made JS converter: http://www.showdown.im/
You can use it like this: