I have this code:
<h4><img class="arrow" src="/Images/page-elements/arrow-light-blue.png"
alt="" />Day 1: Halifax</h4>
<h4><img class="arrow" src="/Images/page-elements/arrow-light-blue.png"
alt="" />Day 2: Halifax – Pictou (2 hours)</h4>
<h4><img class="arrow" src="/Images/page-elements/arrow-light-blue.png"
alt="" />Day 1: London</h4>
<h4><img class="arrow" src="/Images/page-elements/arrow-light-blue.png"
alt="" />Day 2: Halifax – Victoria (2 hours)</h4>
I am using:
SELECT * FROM abc WHERE `meta_value` RLIKE 'Day[^>]+</h4>'
in MySQL, which selects everything from 'Day' to the ending </h4>
tag.
I want it to only select stuff which has "Victoria" in it. So I want it to select only "Day 2: Halifax – Victoria (2 hours)</h4>"
How can I do this? I tried %Victoria%
but it doesn't work.
Use an expression like:
RLIKE 'Day.*Victoria'
RLIKE 'Victoria[^<]*/h4>'
Details
Victoria -- look for this
[^<]* -- match everything through the start of next tag
/h4> -- make sure that tag is "end h4" (and include it in the match)
So far, this Q&A is ignoring what the OP probably wants -- namely to extract the substring from the text. This is impractical in MySQL; use MySQL to find the row, then use app code to do the extraction.