我想使用 Xidel 选择一个<section>
标签,其中class="body"
if 包含格式中的日期,YYYY.M(M).D(D)
以查找并提取一个具有 8 个字符且可以包含字符和数字的特定字符串。
示例输入 HTML:
<section class="body">
Start 2019.1.12
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
thi1te_t
</section>
命令:
xidel -s input.html -e "//*[@class='body' and contains(text(),'(20\d{2}).(\d{1,2}).(\d{1,2})')]"
出于某种原因,我无法让这个正则表达式工作。在regex101.com 上它工作正常。
我想获得thi1te_t
最终输出,可能使用正则表达式^.{8}$
和 grep。