Regexp

Discussion in 'Linux Admins, Storage and Virtualization' started by VlaKl, Oct 4, 2019.

  1. VlaKl

    VlaKl New Member

    Joined:
    Apr 26, 2019
    Messages:
    23
    Likes Received:
    0
    Hi
    For what \b(?:[1-9][0-9]*)\b ?:
    Google told me:
    (?:...)
    A non-capturing version of regular parentheses. Matches whatever regular expression is inside the parentheses, but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern.

    , but I didn't understand. Tell us in a simple way please
     
    #1
  2. cageek

    cageek New Member

    Joined:
    Jun 22, 2018
    Messages:
    7
    Likes Received:
    1
    Normally, the expressions in (...) are captured and available to caller somehow. The (?:...) prevents the expression from being captured. E.g., see the difference in 1 and 2:

    #!/usr/bin/perl
    print "1: " . join(',','abc' =~ /(a)(b)(c)/) ."\n";
    print "2: " . join(',','abc' =~ /(a)(?:b)(c)/) ."\n";

    Output:
    1: a,b,c
    2: a,c

     
    #2
  3. VlaKl

    VlaKl New Member

    Joined:
    Apr 26, 2019
    Messages:
    23
    Likes Received:
    0
    Thank.
    What is the difference between \b(?:[1-9][0-9]*)\b and \b([1-9][0-9]*)\b ?
     
    #3

Share This Page