Python和Regex无法在字符串中找到序列

时间:2017-05-23 14:56:48

标签: python regex findall

您好我有以下字符串:

t = '<td align="right" class="ofGridLinesTop" headers="amount" sortvalue="2633.33" valign="top">\n\t\t\t\t\t  \n\t\t\t\t\t  \n\t\t\t\t\t  \n\t\t\t\t\t\t$2,633.33\n\t\t\t\t\t  \n\t\t\t\t\t  \n\t\t\t\t\t</td>'

我知道以下正则表达式序列正确识别了我想要的字符串部分(sortvalue =“2633.33”)

\bsortvalue=.\b\d+.\d+.

然而,当我使用以下声明时:

Amt = re.findall('\bsortvalue=.\b\d+.\d+.',t)

我空了。知道为什么吗?

1 个答案:

答案 0 :(得分:1)

使用此:

<?php
$hourToCheck = $p_objetct->getHour();
$currentHour = date('H'); // As of PHP manual "H" returns the hour in 24h format

$contentToDisplay = "What ever you wanna display as default.";
if ($hourToCheck <= $currentHour) {
    $contentToDisplay = "Your matching content 1.";
}

或者这个:

Amt = re.findall('\\bsortvalue=.\\b\d+.\d+.',t)

另见this question