Regular expressions: Difference between revisions

Line 1,084:
=={{header|M2000 Interpreter}}==
We can use COM objects so we can use VBscript.RegExp
 
Properties Count and List() are bound with MyMatches using smart pointer. So MyMatches can change object, and Count and List() can operate with new object.
 
Com objects always have one real pointer. We can't returned id (because at the exit of module or function where we create it pointer get Nothing, so properties have a "broken" pointer, and return of object returns a broken smart pointer). We can pass by reference com objects, or we can use it as Globals (until "mother" module finish). We can use WithEvent if we wish to get events. We have to make functions with object_event name (note that forms event use dot not underscore).
 
We can use named parameters (for Word) Try {Method Documents, "add", "", DocumentType:=WdNewWebPage as doc1}
 
 
<lang M2000 Interpreter>
Module CheckIt {
Line 1,115 ⟶ 1,123:
Pattern$ = "(\S+), (\S+)"
Print RegEx.Replace$("Myer, Ken", "$2 $1")
Method ObjRegEx, "Execute", "Myer, Ken" as MyMatches
For i=0 to Count-1 : Print List$(i) : Next i
declare ObjRegEx Nothing
}
Anonymous user