[英]Read values in numeric xml tags using Regex
I need to read the values of numeric xml tags. 我需要读取数字xml标签的值。 eg
例如
<101>ThisIsOneValue</101>
I want one REGex that gives me "ThisIsOneValue" 我想要一个正则表达式给我“ ThisIsOneValue”
Very easy: just look for >
line per line (/ g
) and grab the text that goes after it. 非常简单:只需查找
>
每行(/ g
)行,然后获取紧随其后的文本。
/\\>(.*)/g
should do it. /\\>(.*)/g
应该可以。
See https://regex101.com/r/lO1lT5/1 for an example. 有关示例,请参见https://regex101.com/r/101lT5/1 。
If your text would also happen to contain a >
, then you can test for <
, digits and then >
, through eg \\<\\d+\\>(.*)
, see https://regex101.com/r/lO1lT5/2 . 如果您的文本也恰好包含一个
>
,则可以通过例如\\<\\d+\\>(.*)
来测试<
,数字然后是>
,请参见https://regex101.com/r/lO1lT5/2 。
Per the new info: https://regex101.com/r/lO1lT5/3 (use \\<\\d+\\>(\\w*)\\<\\/\\d+\\>
) 根据新信息: https : //regex101.com/r/lO1lT5/3 (使用
\\<\\d+\\>(\\w*)\\<\\/\\d+\\>
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.