/*
Remove any leading spaces from a string
*/
string s = " leading spaces Example String"
int pos
for (pos = 0 ; pos < length(s) ; pos++)
{
if( s[pos] != ' ') //if (! isspace(s[pos]))
{
break
}
}
print s[pos:]
You could also make use of a function –
string removeSpaces(string s)
{
int pos = 0
while(isspace(s[pos]))
{
pos++
if(pos > length(s)) return ""
}
return s[pos:]
}
print removeSpaces(" leading spaces")
DOORS DXL Scripting Examples – 2
This post was published by Admin.
Email: admin@TheCloudStrap.Com
