Page 1 of 1

ExtractRegularExpression + Structured Arrays

Posted: Wed Jul 03, 2013 12:16 pm
by !ns0
:( I'm very unhappy with that ExtractRegularExpression function can't write results to Structured Array.

It will be very nice if something like this will be implemented:

Code: Select all

ExtractRegularExpression(0, string$, Array()\Structure1)

Re: ExtractRegularExpression + Structured Arrays

Posted: Wed Jul 03, 2013 10:58 pm
by buddymatkona
Is 5.11 code like this is no longer allowed in 5.12? If so, then +1. A safe alternative might be to limit results to space available within structures.

Code: Select all

Structure MyStruct
  Array  MyArray.s(100)
EndStructure

Define MS.MyStruct
subject.s = " addonaddedaddition add readd added addadd "
pattern.s = "\w*add\b"
id.i = CreateRegularExpression(#PB_Any, pattern)

  If id
    NbFound = ExtractRegularExpression(id, subject, MS\MyArray())
    For k = 0 To NbFound-1 : Debug MS\MyArray(k) :Next
  Else
    Debug RegularExpressionError() : End
  EndIf