xHarbour Reference Documentation > Function Reference |
|
|
HB_RegExReplace()
Searches and replaces characters within a character string using a regular expression.
Syntax
HB_RegExReplace(<cRegEx> , ;
<cString> , ;
<cReplace> , ;
[<lCaseSensitive>], ;
[<lNewLine>] , ;
[<nMaxMatches>] , ;
[<nWichMatch>] ) --> cNewString
Arguments
- <cRegEx>
- This is a character string holding the search pattern as a literal regular
expression. Alternatively, the return value of HB_RegExComp()
can be used.
- <cString>
- This is the character string being searched for a match.
- <cReplace>
- A character string that replaces all matched substrings in <cString>.
- <lCaseSensitive>
- This parameter defaults to .T. (true) so that the resulting compiled regular expression
performs a case sensitive search. Passing .F. (false) results in a case insensitive search.
- <lNewLine>
- This parameter defaults to .F. (false).
- <nMaxMatches>
- This is a numeric value indicating the maximum number of replacements. The
default value is zero which replaces all matches.
- <nWichMatch>
- This parameter is numeric and specifies the type of matches to replace. It defaults
to zero which means that the function replaces the whole match and sub-matches, if any.
The value 1 instructs the function to replace only whole matches, 2 means the first
sub-match in the whole match, 3 is the second sub-match in the whole match, and so forth.
Return
The function returns a copy of <String> where substrings matching the regular expression
are replaced with <cReplace>.
Description
Function HB_RegExReplace() searches a character string using a regular expression
and replaces matching substrings with <cReplace>. It is similar to the function
StrTran() but more powerful since the search condition is a regular expression.
Info
See also: | HAS, HB_AtX(), HB_RegEx(), HB_RegExAll(), HB_RegExComp(), HB_RegExSplit(), LIKE, StrTran(), Stuff() |
Category: |
Character functions
, Regular expressions
, xHarbour extensions |
Source: | rtl\regexrpl.prg |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe