如何检查条件正则表达式中的完整单词?

时间:2018-03-22 23:21:22

标签: regex if-statement conditional

使用此文:

sessionInfo()

R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.4.3 tools_3.4.3  

我需要一个条件语句,基本上说:

如果链接中显示文字'font color =“red”',请匹配'html“>'。

我一直在尝试以下代码:

<li><a href="html/Inpatient/3,40060.html"> Informaci<font color="red">ó</font>n para los maestros y la escuela</a></li>

但选择最终被分解成碎片,并且没有进行比赛。有什么想法吗?

{{3}}

1 个答案:

答案 0 :(得分:1)

The proper way using :

//a[font[@color="red"]]

or in a shell :

xmllint --html --xpath '//a[font[@color="red"]]' file |
    grep -o 'html">'

Output:

html">