strstrip


The strstrip function strips one or both emclosing characters and then trims leading and trailing blanks. If no enclosing characters are matched, only preceding and trailing blanks are stripped. Note that only the leading and trailing characters (if specified) are stripped, hence an embedded leading or trailing character is not removed.

Syntax

sNewString = strstrip( sString, sLead, sTrail )

bullet.gif    sString is the string to be processed.

bullet.gif    sLead is the optional leading character to be stripped.

bullet.gif    sTrail is the optional trailing character to be stripped.

bullet.gif    sNewString is the result.

bullet.gif    sNewString = nil if not a string.

Example

The scripts below show several cases of stripping termain characters and blanks. Note that only the leading and trailin:

s = "[ John ny ]"

-- string with [] and blanks

Printf("new=%s\n", strstrip(s, "[", "]"))

- prints new=John ny

 

 

s = " John ny /"

-- string with end blanks

Printf("new=%s\n", strstrip(s, "/", "]"))

- prints new=John ny /

 

 

s = "[ 'John 'ny ' / "

-- string

Printf("new=%s\n", str2str(s, "[", "/"))

- prints new='John ny ' /

 

 

s = "/ 'John 'ny ' / "

-- not a string

Printf("new=%s\n", str2str(s, "/", "/"))

-- prints new='John 'ny ' /

Related Topics

String Type Functions

str2str


Mira Pro x64 Script User's Guide, v.8.77 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.