Opened 13 years ago
Closed 13 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 Changed 13 years ago by TicketCleanup
- Version 3.3.6.1 deleted
comment:2 Changed 13 years ago by jmichae3@…
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 ")&"""")
comment:3 Changed 13 years ago by anonymous
by the way, forum is closed to posts and registration.
comment:4 follow-up: ↓ 5 Changed 13 years ago by anonymous
Can be accomplished with StringRegExpReplace and probably with other functions.
comment:5 in reply to: ↑ 4 Changed 13 years ago by anonymous
Replying to anonymous:
Can be accomplished with StringRegExpReplace and probably with other functions.
or with StringStripWS
comment:6 Changed 13 years ago by Valik
- Resolution set to Rejected
- Status changed from new to closed
StringStripWS() already has options for stripping leading (left) and trailing (right) whitespace.
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Automatic ticket cleanup.