I have a text:
<font class="myclass">class abc</font>
and i have a pattern: class
now, i want to find the word “class” before “abc” but not in the <font class="myclass"> ,how could i do with RegExp in javascript?
Thanks! 🙂
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.
Darin’s comment is spot on — don’t use RegEx to parse HTML.
If, however, you have a very narrow requirement to find the word “class” immediately following a
>, here’s your pattern:>classThere is a space at the end. If you need to capture “class” for replacement, surround it with parentheses
( ), then use the capture group\1.This is not terribly robust, but is a start and is only applicable for a very narrow search requirement, not for any more involved parsing.