<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Trimming_%28computer_programming%29</id>
	<title>Trimming (computer programming) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Trimming_%28computer_programming%29"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Trimming_(computer_programming)&amp;action=history"/>
	<updated>2026-05-13T15:12:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Trimming_(computer_programming)&amp;diff=2652155&amp;oldid=prev</id>
		<title>imported&gt;SchlurcherBot: Bot: http → https</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Trimming_(computer_programming)&amp;diff=2652155&amp;oldid=prev"/>
		<updated>2025-04-08T10:53:17Z</updated>

		<summary type="html">&lt;p&gt;Bot: http → https&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Refimprove|date=February 2015}}&lt;br /&gt;
&lt;br /&gt;
In [[computer programming]], &amp;#039;&amp;#039;&amp;#039;trimming&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;trim&amp;#039;&amp;#039;&amp;#039;) or &amp;#039;&amp;#039;&amp;#039;stripping&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;strip&amp;#039;&amp;#039;&amp;#039;) is a [[string (computer science)|string manipulation]] in which leading and trailing [[whitespace character|whitespace]] is removed from a [[string (computer science)|string]].&lt;br /&gt;
&lt;br /&gt;
For example, the string (enclosed by apostrophes)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&amp;#039;  this is a test  &amp;#039;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
would be changed, after trimming, to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=text&amp;gt;&amp;#039;this is a test&amp;#039;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Variants==&lt;br /&gt;
&lt;br /&gt;
===Left or right trimming===&lt;br /&gt;
&lt;br /&gt;
The most popular variants of the trim function strip only the beginning or end of the string. Typically named &amp;#039;&amp;#039;&amp;#039;ltrim&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;rtrim&amp;#039;&amp;#039;&amp;#039; respectively, or in the case of Python: &amp;#039;&amp;#039;&amp;#039;lstrip&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;rstrip&amp;#039;&amp;#039;&amp;#039;. C# uses &amp;#039;&amp;#039;&amp;#039;TrimStart&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;TrimEnd&amp;#039;&amp;#039;&amp;#039;, and Common Lisp &amp;#039;&amp;#039;&amp;#039;string-left-trim&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;string-right-trim&amp;#039;&amp;#039;&amp;#039;. Pascal and Java do not have these variants built-in, although [[Object Pascal]] (Delphi) has &amp;#039;&amp;#039;&amp;#039;TrimLeft&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;TrimRight&amp;#039;&amp;#039;&amp;#039; functions.&amp;lt;ref&amp;gt;{{cite web|url=https://www.freepascal.org/docs-html/rtl/sysutils/trim.html |title=Trim |publisher=Freepascal.org |date=2013-02-02 |access-date=2013-08-24}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Whitespace character list parameterization===&lt;br /&gt;
&lt;br /&gt;
Many trim functions have an optional parameter to specify a list of characters to trim, instead of the default whitespace characters. For example, PHP and Python allow this optional parameter, while Pascal and Java do not. With Common Lisp&amp;#039;s &amp;lt;code&amp;gt;string-trim&amp;lt;/code&amp;gt; function, the parameter (called &amp;#039;&amp;#039;character-bag&amp;#039;&amp;#039;) is required. The C++ [[Boost library]] defines space characters according to [[Locale (computer software)|locale]], as well as offering variants with a [[predicate (computer programming)|predicate]] parameter (a [[functor]]) to select which characters are trimmed.&lt;br /&gt;
&lt;br /&gt;
===Special empty string return value===&lt;br /&gt;
&lt;br /&gt;
An uncommon variant of trim returns a special result if no characters remain after the trim operation. For example, [[Jakarta Project|Apache Jakarta]]&amp;#039;s &amp;#039;&amp;#039;&amp;#039;StringUtils&amp;#039;&amp;#039;&amp;#039; has a function called &amp;lt;code&amp;gt;stripToNull&amp;lt;/code&amp;gt; which returns &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; in place of an empty string.&lt;br /&gt;
&lt;br /&gt;
===Space normalization===&lt;br /&gt;
&lt;br /&gt;
Space normalization is a related string manipulation where in addition to removing surrounding whitespace, any sequence of whitespace characters within the string is replaced with a single space. Space normalization is performed by the function named &amp;lt;code&amp;gt;Trim()&amp;lt;/code&amp;gt; in spreadsheet applications (including [[Microsoft Excel|Excel]], [[OpenOffice.org Calc|Calc]], [[Gnumeric]], and [[Google Docs]]), and by the &amp;lt;code&amp;gt;normalize-space()&amp;lt;/code&amp;gt; function in [[XSL Transformations|XSLT]] and [[XPath]], &lt;br /&gt;
&lt;br /&gt;
===In-place trimming===&lt;br /&gt;
&lt;br /&gt;
While most algorithms return a new (trimmed) string, some alter the original string [[in-place]]. Notably, the [[Boost library]] allows either in-place trimming or a trimmed copy to be returned.&lt;br /&gt;
&lt;br /&gt;
==Definition of whitespace==&lt;br /&gt;
The characters which are considered whitespace varies between programming languages and implementations. For example, C traditionally only counts space, tab, line feed, and carriage return characters, while languages which support [[Unicode]] typically include all Unicode space characters. Some implementations also include [[ASCII]] control codes (non-printing characters) along with whitespace characters.&lt;br /&gt;
&lt;br /&gt;
Java&amp;#039;s trim method considers ASCII spaces and control codes as whitespace, contrasting with the Java &amp;lt;code&amp;gt;isWhitespace()&amp;lt;/code&amp;gt; method,&amp;lt;ref&amp;gt;{{cite web|url=https://java.sun.com/j2se/1.5.0/docs/api/java/lang/Character.html#isWhitespace(char) |title=Character (Java 2 Platform SE 5.0) |publisher=Java.sun.com |access-date=2013-08-24}}&amp;lt;/ref&amp;gt; which recognizes all Unicode space characters.&lt;br /&gt;
&lt;br /&gt;
Delphi&amp;#039;s Trim function considers characters U+0000 (NULL) through U+0020 (SPACE) to be whitespace.&lt;br /&gt;
&lt;br /&gt;
=== Non-space blanks ===&lt;br /&gt;
The [[Braille Patterns]] Unicode block contains {{unichar|2800|Braille pattern blank|html=}}, a [[Braille]] pattern with no dots raised. &lt;br /&gt;
The Unicode standard explicitly states that it does not act as a space.&lt;br /&gt;
&lt;br /&gt;
The [[Non-breaking space]] {{unichar|00A0|NO-BREAK SPACE|html=}} can also be treated as non-space for trimming purposes.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
{{Main|Comparison of programming languages (string functions)#trim}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[https://www.tcl.tk/man/tcl8.4/TclCmd/string.htm#M46 Tcl: string trim]&lt;br /&gt;
*[https://blog.stevenlevithan.com/archives/faster-trim-javascript Faster JavaScript Trim] - compares various JavaScript trim implementations&lt;br /&gt;
*[http://webwidetutor.com/php/PHP-Change-String-value-behaviour-or-look-?id=8 php string cut and trimming]- php string cut and trimming&lt;br /&gt;
&lt;br /&gt;
[[Category:Articles with example code]]&lt;br /&gt;
[[Category:String (computer science)]]&lt;/div&gt;</summary>
		<author><name>imported&gt;SchlurcherBot</name></author>
	</entry>
</feed>