need regex command to extract full filename which has 2 dot(.)

Viewed 79

i am having issue in extracting full filename which has 2 dot(.).
although below command is working but i need a alternate solution without asterix in regex. can anyone help me out in alternate regex command to extract full filename without asterix?

(ABC_A.*\.)+.*  

Here are filenames I am trying to match:

ABC_A_CommunityRollover_Autocreate_Community.12345678-1.out
ABC_A_CommunityRollover_Autocreate_Community.88345678-1.out
ABC_A_CommunityRollover_Autocreate_Community.99945678-1.out
1 Answers

TL;DR:

^ABC_A(?:[^.]+\.){2}[^.]+$

Live Demo.

EXPLANATION

--------------------------------------------------------------------------------
  ^                        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
                           string
Related