Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
STRTRIM seems not to be working
Author Message
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #1
STRTRIM seems not to be working
using jul31 dev ....

im trying to eat the spaces in a text with strtrim but doesnt seem to work...

example

serv.log <strtrim whats up dude>

returned text log: whats up dude
08-08-2014 03:37 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: STRTRIM seems not to be working
This function be used to strip all whitespace (spaces, tabs, newlines) from the start and end of a string. Tongue
08-08-2014 03:40 AM
Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #3
RE: STRTRIM seems not to be working
same result here on August 4th build, 2014.

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
08-08-2014 03:49 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #4
RE: STRTRIM seems not to be working
good to know its not only me xD
08-08-2014 04:15 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #5
RE: STRTRIM seems not to be working
Trimming removes the white-spaces just in the beginning and end of the string, not in the middle and so on.. Big Grin
08-08-2014 04:21 AM
Find all posts by this user Like Post Quote this message in a reply
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #6
RE: STRTRIM seems not to be working
omg... so is it possible to remove whitespaces in middle of a string?

i guess its necessary some strsub and strlen or streat and strarg >.<
(This post was last modified: 08-08-2014 04:51 AM by kn4tseb.)
08-08-2014 04:48 AM
Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #7
RE: STRTRIM seems not to be working
Yes:
Code:
[function removespaces]
local.args=<args>
while !(strmatch(0,<local.args>)) && !(strmatch(00,<local.args>))
  local.return=<strarg <local.args>>
  local.args=<streat <local.args>>
endwhile
return <local.return>
load this script and type something like .show removespaces test test test. It should return 'testtesttest'.

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
08-08-2014 05:49 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #8
RE: STRTRIM seems not to be working
Taken from: http://forum.spherecommunity.net/Thread-Spaces
(12-05-2013 09:06 AM)XuN Wrote:  StrTrim only works for spaces at begin of given string, if you want to remove any spaces from the text they Input use <asciiremove 32,<argtxt[0]>>

Code:
[function asciiremove]
local.ascii=<argv[0]>        //Ascii Dec value of the character we want to remove, for detailed information and IDs look http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters
local.text=<streat <args>>    //Text to remove <local.ascii>
local.check=<strpos 0 <dlocal.ascii> <args>>    //We check if we have any specified ascii chr to remove
while <local.check>>0    //If so we begin
    local.len=<eval STRLEN(<local.text>)>    //Length of the text
    local.pos=<strpos 0 <dlocal.ascii> <local.text>>    //Position of current ascii char found
    if (<local.pos>==0)    //If ascii is first char we make aditional IF to remove it
        local.text=<strsub <eval <local.pos>+1> <local.len> <local.text>>    //local.text=Text except first character
    else    //Otherwise we can do whole replacement with one line
        local.text=<strsub 0 <local.pos> <local.text>><strsub <eval <local.pos>+1> <local.len> <local.text>>    //Text until found charText from found char (without spaces nor anything)
    endif
    if (<strpos 0 <dlocal.ascii> <local.text>>==-1)    //We check if we have more ascii chars to remove
        local.check=0    //and we set to 0 if not, to stop while.
    endif    
endwhile
return <local.text>        //Fixed text
08-08-2014 07:09 AM
Find all posts by this user Like Post Quote this message in a reply
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #9
RE: STRTRIM seems not to be working
Thank you both! Smile
08-08-2014 07:15 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)