我在提取带有两个点(.)的完整文件名时遇到问题。
虽然下面的命令是有效的,但我需要在regex中没有asterix的替代解决方案。有没有人可以帮助我在替代的regex命令提取完整的文件名没有asterix?
(ABC_A.*\.)+.* 以下是我正在尝试匹配的文件名:
ABC_A_CommunityRollover_Autocreate_Community.12345678-1.out
ABC_A_CommunityRollover_Autocreate_Community.88345678-1.out
ABC_A_CommunityRollover_Autocreate_Community.99945678-1.out发布于 2021-05-13 05:08:23
TL;DR:
^ABC_A(?:[^.]+\.){2}[^.]+$。
说明
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
ABC_A 'ABC_A'
--------------------------------------------------------------------------------
(?: group, but do not capture (2 times):
--------------------------------------------------------------------------------
[^.]+ any character except: '.' (1 or more
times (matching the most amount
possible))
--------------------------------------------------------------------------------
\. '.'
--------------------------------------------------------------------------------
){2} end of grouping
--------------------------------------------------------------------------------
[^.]+ any character except: '.' (1 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
$ before an optional \n, and the end of the
stringhttps://stackoverflow.com/questions/67031505
复制相似问题