G
G
geniusperson2018-06-25 13:07:50
Regular Expressions
geniusperson, 2018-06-25 13:07:50

How to parse a class in regular expressions?

Hello everyone, how to parse a class in regular expressions if it is not in all places?
Here is the html example
image.png
Here is the written code
https://regex101.com/r/ea70gt/1
The code works fine when I remove the class=\"(.+?)\", however it does not parse the class, and when I add the class it does not work because for the fact that not all places have a class.
How to solve this issue?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Farwisdomer, 2018-06-25
@Farwisdomer

use XPath and don't force the brain.

Y
Yan-s, 2018-06-25
@Yan-s

if I start redoing it again, a lot of time will pass

You don't need to parse anything with regular expressions. There are a bunch of libraries for parsing dom. No matter how much time it takes (and it will take much less time than you spent on regular seasons), redo it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question