in reply to Re: a regular expression question
in thread a regular expression question

i know the netgroup file i'm processing probably doesn't have 3 spaces before the first comma, what if it does?

i thought regular expression matches the short possible pattern, not the longest, am i wrong?

Replies are listed 'Best First'.
Re^3: a regular expression question
by roboticus (Chancellor) on Dec 18, 2012 at 15:41 UTC

    brassbin:

    As toolic mentioned, the .* construct is greedy and tries to get the longest match. If you turn it into .*?, it then looks for the shortest match. If you read the link he provided, you could verify that yourself.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      Thank you toolic, roboticus!

      i haven't figured out all the rules yet of posting, but i meant to say thank you for your help

      i don't know why a line that contains the words

      thank you

      doesn't show up