hyTags
HomeHome DocumentationDocumentation

string-trim

Removes specified characters from the beginning and/or end of a string.
Parameter
Type
Description
self
String
String to trim
characters
String?
Characters to remove (defaults to whitespace if nil)
side
String?
Which side to trim: "left", "right", or both sides if nil
return
string
String with specified characters removed
Test Case:Trim whitespace
    <div></div>
    
    <string-new value="  hello  ">
    <string-trim>
    <assert-equal value="hello" type="string">
    
    👆 Try to change something!
  • Test Case:Trim custom characters
      <div></div>
      
      <string-new value="xxhelloxx">
      <string-trim characters="x">
      <assert-equal value="hello" type="string">
      
      👆 Try to change something!
    • Test Case:Trim left only
        <div></div>
        
        <string-new value="xxhelloxx">
        <string-trim characters="x" side="left">
        <assert-equal value="helloxx" type="string">
        
        👆 Try to change something!
      • Test succeeded Test failed