| Examples:
A first example uses sub-expression "\\1" that
supply expression in the parentheses (e.g. "\\0"
supply a whole expression). Regular
Expressions use an own escape sequences. If "LC Basic
escape sequences" are enabled (viz. HBEEnableEsc),
you must use double backslash ("\\1") instead single
backslash ("\1"). A command HBESubExp
can be used in the sCondition but not in the string2.
Syntax "\\1" must be used for sub-expression in
string2 and can be use in the sCondition also.
'Removes All Links.
HBEReplaceAllRE("<\\s*A[^>]*?href.*?>(.*?)</A>","\\1")
'Removes All Blank Lines.
HBEReplaceAllRE("^\\s*$.?","")
'Script replaces all occurences of "sample"
'to "example" but only if tag "<html>" is present.
HBEReplaceAllRE("sample","example", False, "HBEFind(\"<html>\")")
'escape sequences \" must be used for quotation marks.
'following syntax is equivalent:
sCondition = "HBEFind(\"<html>\")"
HBEReplaceAllRE("sample","example", False, sCondition)
sCondition = "HBEFind(\"<html>\") > 0"
HBEReplaceAllRE("sample","example", False, sCondition)
Condition must be string. You cannot use this syntax:
HBEReplaceAllRE("sample","example", False, HBEFind("<html>"))
In this case the condition would be evaluated only once.
A function work with a string condition internally and automatically
evaluate this condition at that time when next occurence is
found.
Following example shows the same code without using HBEReplaceAllRE.
nWhere = HBEFind("sample",0,False)
len = FOUNDLEN
While (nWhere>0)
If (HBEFind("<html>"))
HBEReplace (nWhere,len,"example")
EndIf
nWhere = HBEFind("sample",nWhere,False)
len = FOUNDLEN
EndWhile
HBEFlush()
|