Answer the question
In order to leave comments, you need to log in
How to extract a word from a string using a regular expression?
Given a line
<div class="title"><a href="/kakoytoadres/adress">СЛОВО</a></div>
located in a heap of html code. So far I'm using /title"(.*?)\/a/is
to pull out the title line, how do I get only the WORD?
Answer the question
In order to leave comments, you need to log in
serious guys use a DOM parser for this,
novice guys quickly master the construction
i.e. for your case
, they quickly realize that the opposite case:
to extract - they take it in brackets
and get it as a result
PS
advanced guys remember that spaces and other shnyags can be inserted between tags <div[^>]+>\t\n?<a[^>]+>
- here with \t\n and ? get angry, too lazy to check, you need to note when it may or may not be,
but mastering the Xpath expression is much more productive
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question