Help with the trimleft/trimright function

 

I've taken my favourite script and tried to learn from it. It's probably is a bit complicated for a beginner but I really wanted to add a function to trim any leading and trailing whitespace characters and also add an option for Title case and Sentence case. I read the manual and all I can see is:

 ToLower + ToUpper

Is there another way to achieve Title case and Sentence case?

Any code that I've modified has --------------#### 3dwannab code ###-------------- beside it.

The area that needs attention is:

--------------#### 3dwannab code ###--------------

( if trailing_leading = false then

for i in selection do i.name = trimleft trailing_leading

--------------#### 3dwannab code ###--------------

 

I'm completely suck at the minute and I wanted to chat with someone on here to help me figure out what I need to do. I've managed to get the presets working as they should. It's just the function that needs a look at.

Thanks

 

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

...

Not have time to look over the whole code.
Post me a snippet to see what is the problem.
Like this

let say i have en string *str*

--example#1 trimLeft | trimeRight fn
str = "--------------####  3dwannab code  ###--------------"
--to remove symbols you can use
str = trimLeft (trimRight str "  ###--------------") "--------------####  "
-->result: "3dwannab code"
 
 
--example#2 replace fn
str = "--------------####  3dwannab code  ###--------------"
--define simbols that you want to remove
toDel = "-+*/|#$"
for i = str.count to 1 by -1 where (findstring toDel str[i]) != undefined do str=(replace str i 1 "") ; str
--> result:"  3dwannab code  "  

bga

barigazy's picture

...

Not quite understand what do you want to achive.
Just show me string before and after (result that you want)

bga

johnsu6616's picture

...

Thank you so much.
Your information really helped me a lot!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.