我有以下案文
1样式索引法线+速递新T201_LLR_001|2样式索引法线+信使新应接受三个指针。
我需要转换这个文本才能得到三个独立的输出
我使用了以下常规(\S+_LLR_\d+)(.+)\t(SSC_.+)*
以获得以下输出
但是,我需要去掉文本|2 Style Indented Normal + Courier New" and "|3 Style Indented Normal + Courier New
在正则表达式中有可能吗?我不知道如何使用(?!TEXT)。
发布于 2013-08-07 13:03:40
对于那些没有注意到的人,我看到字体和你想要的字符串之间有一个选项卡,这使得问题变得更容易了。
这应该给你你想要的:
([^_\s]+_LLR_\d+)[^\t]*\t([^|]*)[^\t]*\t(SSC_.+)解释:
我将\S (非空白)更改为[^_\s] (不是下划线或空白)。
然后消费T201_LLR_001。
然后,您将使用所有的东西,包括下一个选项卡,它将是|2 Style Indented Normal + Courier New。
然后,您将使用|中的所有内容,这将是Shall accept the three pointers.,并将其放在方括号中存储在一个组中。
然后,您将使用所有的东西,包括下一个选项卡,它将是|3 Style Indented Normal + Courier New。
然后使用SSC_01_SRS_0001并将其放在一个组中。
Java测试正确地打印出:
T201_LLR_001
Shall accept the three pointers.
SSC_01_SRS_0001发布于 2013-08-07 09:51:37
使用另一个组来捕获|2 Style Indented Normal + Courier New和|3 Style Indented Normal + Courier New。如果您愿意,甚至可以使用非捕获组(?:)。
发布于 2013-08-07 10:09:21
试试这个(.NET):
(?<=\|\d \w* \w* \w* \+ [a-z-A-Z0-9 ]*\t)[\w ]*或者这个:
(?<=\|\d [a-zA-Z+ ]*\t)[\w ]*https://stackoverflow.com/questions/18099647
复制相似问题