且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正则表达式 - 从给定的字符串中提取子字符串

更新时间:2022-03-23 22:28:58

纯 XPath 解决方案:

substring-after('This is a string: AAA123456789', ': ')

生产:

AAA123456789

XPath 2.0 解决方案:

tokenize('This is a string: AAA123456789 but not an double',
              ' '
              )[starts-with(., 'AAA')]

或:

tokenize('This is a string: AAA123456789 but not an double',
              ' '
              )[matches(., 'AAA\d+')]

或:

replace('This is a string: AAA123456789 but not an double',
              '^.*(A+\d+).*$',
              '$1'
              )