Vin*_*ent 9 regex xpath substring
我这里有一个字符串This is a string: AAA123456789.
所以这里的想法是AAA123456789使用正则表达式提取字符串.
我将它与X-Path结合在一起.
注意:如果有帖子,请引导我.
我认为,正确的,我应该substring(myNode, [^AAA\d+{9}]),
我不太确定正则表达式部分.
我们的想法是在遇到"AAA"时提取字符串,只有数字,但只有9个后续数字.
纯XPath解决方案:
substring-after('This is a string: AAA123456789', ': ')
Run Code Online (Sandbox Code Playgroud)
产生:
AAA123456789
Run Code Online (Sandbox Code Playgroud)
XPath 2.0解决方案:
tokenize('This is a string: AAA123456789 but not an double',
' '
)[starts-with(., 'AAA')]
Run Code Online (Sandbox Code Playgroud)
要么:
tokenize('This is a string: AAA123456789 but not an double',
' '
)[matches(., 'AAA\d+')]
Run Code Online (Sandbox Code Playgroud)
要么:
replace('This is a string: AAA123456789 but not an double',
'^.*(A+\d+).*$',
'$1'
)
Run Code Online (Sandbox Code Playgroud)