Strip whitespace from a string/Top and tail: Difference between revisions
Content deleted Content added
Added Delphi example |
Added Nemerle |
||
Line 213: | Line 213: | ||
print( string.format( "Trailing whitespace removed: %s", str:match( "(.-)%s*$" ) ) ) |
print( string.format( "Trailing whitespace removed: %s", str:match( "(.-)%s*$" ) ) ) |
||
print( string.format( "Leading and trailing whitespace removed: %s", str:match( "^%s*(.-)%s*$" ) ) )</lang> |
print( string.format( "Leading and trailing whitespace removed: %s", str:match( "^%s*(.-)%s*$" ) ) )</lang> |
||
=={{header|Nemerle}}== |
|||
<lang Nemerle>def str = "\t\n\t A string with\nwhitespace\n\n\t "; |
|||
WriteLine(str.TrimStart()); |
|||
WriteLine(str.TrimEnd()); |
|||
WriteLine(str.Trim()); // both ends at once, of course, internal whitespace is preserved in all 3</lang> |
|||
=={{header|Objective-C}}== |
=={{header|Objective-C}}== |