Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
foreach and regular expression
#1
I wonder whether it is possible to use in a foreach statement a regular expression in "coll", for example to enumerate files.

I understand I can enumerate files using a regular expression in GetFilesInFolder.

Any advice is much appreciated.
#2
Function FE_RegexExample
Code:
Copy      Help
;/
function str&match $regex $string_ [submatch]

int i k
i=findrx(string_ regex i 0 k submatch)
if(i<0) ret
match.get(string_ i k)
i+k
ret 1

Macro Macro2871
Code:
Copy      Help
str s="qwe 123 rty 45 uio 6"
str match
foreach match "\d+" FE_RegexExample s
,out match

With files better use standard code with FE_Dir, and use findrx in the loop. Regular expression inside a foreach-function like FE_Dir would not make faster.
#3
Many thanks indeed, it is very constructive.


Forum Jump:


Users browsing this thread: 1 Guest(s)