Regular expressions: Difference between revisions

No edit summary
Line 1,083:
 
=={{header|M2000 Interpreter}}==
We can use COM objects so we can use VBscript.RegExp
<lang M2000 Interpreter>
Module CheckIt {
Line 1,089 ⟶ 1,090:
Method ObjRegEx, "Replace", from$, what$ as response$
=response$
}
Function RegEx.Test(what$) {
Method ObjRegEx, "Test", what$ as response
=response
}
Print Type$(ObjRegEx)
With ObjRegEx, "Global", True, "Pattern" as pattern$
pattern$="Mona Lisa"
Print RegEx.Test("The Mona Lisa is in the Louvre.")=true
Print RegEx.Replace$("The Mona Lisa is in the Louvre.", "La Gioconda")
Pattern$ = " {2,}"
Line 1,107 ⟶ 1,113:
 
 
\\ internal has no pattern. There is a like operator (~) for strings which use pattern matching (using VB6 like). We can use Instr() and RInstr() for strings.
 
Module Internal {
Line 1,114 ⟶ 1,120:
Find a$, what$
Read FindWhere
If FindWhere<>0 then Read parIndexNoparNo, parlocation
\\ replace in place
Insert FindWhere, Len(what$) a$="La Gioconda"
Line 1,127 ⟶ 1,133:
Internal
</lang>
 
 
=={{header|M4}}==
Anonymous user