www.lucersoft.com

   
       Home  |   News  |   Downloads  |   Order  |   Contacts

 

 

Main

Home

Site map

Products

LC Backup

LC Copier

HTML Batch Editor

HTML Batch Editor PRO

Tennis 2001

Freeware

Documentation

HTML Batch Editor PRO

LC Basic

Information

Order

Update Policy

Support

Contacts

Links

 
 
 
 

 
 
 
 
 
 
 
 
 

HBEReplaceAllRE

HBE specific commands


Syntax

 

result = HBEReplaceAllRE(string1, string2, bCase, sCondition)

 


Description:

 

Replaces all occurrences of string1 in the current file with string2. The Regular Expressions can be used with this function. 


Arguments:

 

string1 - String being searched for.

string2 - Replacement string.

bCase - Determine if searching is case sensitive.

sCondition - The condition, which is applied on all occurences. This condition is LC Basic expression. A result of this condition must be a BOOL value. Because the condition is evaluated several times for any occurence separately, you must enter condition as string.

 


Return value:

 

Count of replaced strings.


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()



See also:

 

HBEReplaceAll, HBEReplace, HBEFind, HBEFindRE, Regular Expressions



 
Last updated: November 2, 2003
Copyright © 2002 Lucersoft

Add to favorites

Back