Peter
Thanks for that explanation!

On Wed, 28 Nov 2018 20:27:40 +0100, Peter Bozek wrote:
> On Wed, Nov 28, 2018 at 7:30 PM Chip Scheide via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> 
>> Thanks Kirk,
>> 
>> According to Wiki :
>> . - matches any single character
>> ( ) - defines a marked subexpression
>> * - matches the preceding element zero or more times
>> so... as I read the definitions...
>> "(.*:)"
>> 
>> match any character(s), before a ":"
>> a file path (on a Mac) is <folder> : <folder> : <folder> ... : <file>
>> 
>> Match Regex says:
>> "...If you pass arrays, the command returns the position and length of
>> the occurrence in the element zero of the arrays and the positions and
>> lengths of the groups captured by the regular expression in the
>> following elements."
>> 
>> so I would expect(ed)
>> Match regex($folderPathMotif;$File_Path;1;$path_pos;$path_len)
>> 
>> to populate the arrays with each occurrence of ":", as your supplied
>> code appears to do,
>> OR
>> if the Match Regex does not find/report all occurrences of ":" to
>> report the FIRST instance of a ":", not the last.
>> 
> 
> Regex behaves like that because, by default, its matching is greedy, what
> means it tries to match the pattern to as many characters as possible. In
> your case, it tries to find longest run that match pattern .*; - and the
> run consist of all characters up to last :.
> 
> If you want the match stop on first occurrence of : you need to make
> operator * ungreedy by attaching ? to it. If you try pattern (.*?:) it
> should return substring up to first :. While pattern .*: says "find the
> longest run of characters ending with :" pattern .*?: means "find the
> shortest run of characters ending with :
> 
> Size of array is number of matching groups, in your case 1. This is how it
> works, IMHO. If the whole pattern repeats itself several times, you need to
> run Match regex in loop.
> 
> HTH,
> 
> --
> 
> Peter Bozek
---------------
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to