Opened 14 years ago
Closed 14 years ago
#2020 closed Feature Request (Rejected)
request: StringLTrim($str) and StringRTrim($str)
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | Cc: |
Description
these functions would either strip the left or right whitespace off of a string. VERY VERY useful. standard keyword in basic (ltrim, rtrim).
Attachments (0)
Change History (6)
comment:1 by , 14 years ago
| Version: | 3.3.6.1 |
|---|
comment:2 by , 14 years ago
working code example of the necessary functions. If you want this coded in C++ I am sure I could do it in less than an hour.
func ltrim($s)
if ""==$s then
return $s
endif
local $s2,$index,$pos=-1,$ch
for $index = 1 to stringlen($s)
if (asc(stringmid($s,$index,1)) > 32) then
$pos=$index
exitloop
endif
next
if (-1<>$pos) then
return StringMid($s,$pos)
endif
return $s
endfunc
func rtrim($s)
if ""==$s then
return $s
endif
local $s2,$index,$pos=-1,$ch
for $index = stringlen($s) to 1 step -1
if (asc(stringmid($s,$index,1)) > 32) then
$pos=$index
exitloop
endif
next
if (-1<>$pos) then
return StringMid($s,1,$pos)
endif
return $s
endfunc
func trim($s)
return ltrim(rtrim($s))
endfunc
;msgbox(0,"test","ltrim"""<rim(" blah ")&"""")
;msgbox(0,"test","rtrim"""&rtrim(" blah ")&"""")
;msgbox(0,"test","trim"""&trim(" blah ")&"""")
follow-up: 5 comment:4 by , 14 years ago
Can be accomplished with StringRegExpReplace and probably with other functions.
comment:5 by , 14 years ago
Replying to anonymous:
Can be accomplished with StringRegExpReplace and probably with other functions.
or with StringStripWS
comment:6 by , 14 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |
StringStripWS() already has options for stripping leading (left) and trailing (right) whitespace.

Automatic ticket cleanup.