我是使用UltraEdit的。我有一个文本文件,其中包含类似以下字符串:
Workspace\\Trays\\Dialogs\\Components, Expand, kThisComputerOnly, P_BOOLEAN },
WebCommonDialog Sign_Out, Left, kThisComputerOnly, P_INTEGER_RANGE(0, 4096) },
ThreeDTextDlg, x, kThisComputerOnly, P_INTEGER_RANGE(0, 4096) },
Preferences\\Graphics, CtxDbgMaxGLVersionMajor, kThisComputerOnly, P_INTEGER },
UltraEdit支持PERL、UNIX和UltraEdit风格的正则表达式。我需要选择第二个逗号和行尾的所有内容并将其删除。
我尝试了几种不同的方法,但在regexpal.com上无法解决它。
/,\s.+/ selects the first comma
/[,]\s.+/ same as above
我无法弄清如何选择第二个及以后的命令。
我也在StackOverflow上搜索了几个示例,但无法将它们更改为适用于我的情况。
谢谢。
^([^,]*,[^,]*),.*
进行替换,并将其替换成\1
。 - Wiktor Stribiżew,.*,
不是语义上相同吗?此外,我认为这不是 OP 想要删除的内容。 - Aaron^([^,]*,[^,]*),.*
选中了整行,但 UltraEdit 没有找到匹配项。 - Brad Askins\1
替换,那么从行开头到第二个,
的部分应该保留。请参见https://regex101.com/r/1mGaCM/1 - Wiktor Stribiżew