RANGEREM()
Remove characters within a certain ASCII range from a string
Syntax
RANGEREM( <cChar1|nChar1>, <cChar2|nChar2>, <cString> ) -> cString
Arguments
<cChar1|nChar1> and <cChar2|nChar2> Designate the first and the last character of the character range.
<cString> Designates the character string that is edited.
Returns
The function returns the modified character string.
Description
RANGEREM() allows you to delete all characters that are in a particular ASCII range. For example, you could delete all control characters in a character string. The designated range can run “back to front”, meaning <cChar2|nChar2> can have a lower value than <cChar1|nChar1>. In such a case the range extends from the larger value to 255 and also from 0 to the smaller value.
Note
. Since the length of the character string is changed, passing by reference will not work here as it does with RANGEREPL().
Examples
. ? rangerem( "0", "9", "year2002.dbf" ) // "year.dbf", remove all digits . ? rangerem( "9", "0", "year2002.dbf" ) // "22", testing removal from "9" to chr(255) // and from chr(0) to "0" . ? rangerem( "0", "9", "yearcurr.dbf" ) // "yearcurr.dbf", test leaving string untouched . Delete all control characters: cString := RANGEREM(0, 31, cString) . Delete all characters that are not upper case, alpha characters: cString := RANGEREM(91, 64, cString)
Tests
rangerem( "0", "9", "year2002.dbf" ) == "year.dbf" rangerem( "9", "0", "year2002.dbf" ) == "22" rangerem( "0", "9", "yearcurr.dbf" ) == "yearcurr.dbf"
Compliance
RANGEREM() is compatible with CT3’s RANGEREM().
Platforms
All
Files
Source is range.c, library is libct.
Seealso
RANGEREPL()
Pingback: Harbour All Functions – R | Viva Clipper !
Pingback: Harbour String Functions | Viva Clipper !