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.
答案 0 :(得分:0)
Use an expression like:
RLIKE 'Day.*Victoria'
答案 1 :(得分:0)
RLIKE 'Victoria[^<]*/h4>'
详细信息
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)
到目前为止,此问与答忽略了OP可能想要的内容-即从文本提取子字符串。这在MySQL中是不切实际的。使用MySQL查找行,然后使用应用程序代码进行提取。