-
Notifications
You must be signed in to change notification settings - Fork 7
/
trim-Method__String.html
executable file
·28 lines (24 loc) · 15.2 KB
/
trim-Method__String.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?xml version="1.0" encoding="utf-8"?><html xmlns:xsl="urn:schemas-microsoft-com:xslt" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:ms-help="http://msdn.microsoft.com/mshelp" xmlns:t="http://www.microsoft.com/topic/t" xmlns:msie="http://www.microsoft.com/ie/msie" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:o="urn:schemas-microsoft-com:office:dvraddata" xmlns:u1="http://www.microsoft.com/vs/dvvwdcon" xmlns:anim="http://www.microsoft.com/windowssdk/anim" xmlns:w="http://www.microsoft.com/windows/w" xmlns:v="http://www.microsoft.com/windows/v" xmlns:msxsl="http://www.microsoft.com/aspnet/cpguide" xmlns:st1="http://www.microsoft.com/webservices/mscomwssdkproject" xmlns:ds="http://www.microsoft.com/xml/xmlsdk/ds" xmlns:xsd="http://www.microsoft.com/xml/xmlsdk/xsd" xmlns:xdr="http://www.microsoft.com/xml/xmlsdk/xdr" xmlns:sql="http://www.microsoft.com/sql/xmlsql" xmlns:ph="http://www.microsoft.com/ph/placeholder" xmlns:xlink="http://www.w3.org/1999/xlink"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="save" content="history" /><title>trim Method (String) (JavaScript)</title><meta name="Language" content="en-us" /><meta name="System.Keywords" content="trim method" /><meta name="Microsoft.Help.Id" content="03d38c7e-25cd-4ede-b58e-1a10b5249bab" /><meta name="Description" content="Removes the leading and trailing white space and line terminator characters from a string." /><meta name="Microsoft.Help.ContentType" content="Reference" /><meta name="Refinement.TopicID" content="196" /><meta name="DCSext.ProductFamily" content="LIB_DG" /><meta name="DCSext.Product" content="VS_JScript" /><meta name="DCSext.Title" content="trim Method (String) (JavaScript)" /><link rel="stylesheet" type="text/css" href="../styles/presentation.css" /><link rel="stylesheet" type="text/css" href="ms-help://Hx/HxRuntime/HxLink.css" /><script type="text/javascript" src="../scripts/EventUtilities.js"><![CDATA[ ]]></script><script type="text/javascript" src="../scripts/SplitScreen.js"><![CDATA[ ]]></script><script type="text/javascript" src="../scripts/Dropdown.js"><![CDATA[ ]]></script><script type="text/javascript" src="../scripts/script_manifold.js"><![CDATA[ ]]></script><script type="text/javascript" src="../scripts/script_feedBack.js"><![CDATA[ ]]></script><script type="text/javascript" src="../scripts/CheckboxMenu.js"><![CDATA[ ]]></script><script type="text/javascript" src="../scripts/CommonUtilities.js"><![CDATA[ ]]></script><xml><mshelp:toctitle title="trim Method (String)" /><mshelp:keyword index="A" term="03d38c7e-25cd-4ede-b58e-1a10b5249bab" /><mshelp:keyword index="K" term="trim method" /><mshelp:attr name="RevisionNumber" value="15" /><mshelp:attr name="AssetID" value="03d38c7e-25cd-4ede-b58e-1a10b5249bab" /><mshelp:attr name="Abstract" value="Removes the leading and trailing white space and line terminator characters from a string." /><mshelp:attr name="TopicVersion" value="8.0.13105.10000" /><mshelp:attr name="Catalog Container" value="System_Default_Catalog" /><mshelp:attr name="Content Set Container" value="System_Default_Content_Set" /><mshelp:attr name="PreferredLib" value="/library/ie" /><mshelp:attr name="Search.Refinement.TopicID" value="196" /><mshelp:attr name="TopicType" value="kbSyntax" /><mshelp:attr name="Locale" value="en-us" /></xml></head><body><input type="hidden" id="userDataCache" class="userDataStyle" /><input type="hidden" id="hiddenScrollOffset" /><img id="collapseImage" style="display:none; height:0; width:0;" src="../icons/collapse_all.gif" alt="Collapse image" title="Collapse image" /><img id="expandImage" style="display:none; height:0; width:0;" src="../icons/expand_all.gif" alt="Expand Image" title="Expand Image" /><img id="collapseAllImage" style="display:none; height:0; width:0;" src="../icons/collapse_all.gif" /><img id="expandAllImage" style="display:none; height:0; width:0;" src="../icons/expand_all.gif" /><img id="dropDownImage" style="display:none; height:0; width:0;" src="../icons/dropdown.gif" /><img id="dropDownHoverImage" style="display:none; height:0; width:0;" src="../icons/dropdownHover.gif" /><img id="copyImage" style="display:none; height:0; width:0;" src="../icons/copycode.gif" alt="Copy image" title="Copy image" /><img id="copyHoverImage" style="display:none; height:0; width:0;" src="../icons/copycodeHighlight.gif" alt="CopyHover image" title="CopyHover image" /><div id="header"><table id="topTable" cellspacing="0" cellpadding="0"><tr><td><span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage, event)" tabindex="0"><img id="toggleAllImage" class="toggleAll" src="../icons/collapse_all.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;">Collapse All</label><label id="expandAllLabel" for="toggleAllImage" style="display: none;">Expand All</label> </span><span>    </span><span id="devlangsDropdown" class="filter" tabindex="0"><img id="devlangsDropdownImage" src="../icons/dropdown.gif" /> <label id="devlangsMenuAllLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: All </nobr></label><label id="devlangsMenuMultipleLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: Multiple </nobr></label><label id="devlangsMenuVisualBasicLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: Visual Basic </nobr></label><label id="devlangsMenuCSharpLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: C# </nobr></label><label id="devlangsMenuManagedCPlusPlusLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: Visual C++ </nobr></label><label id="devlangsMenuFSharpLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: F# </nobr></label><label id="devlangsMenuHLSLLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: HLSL </nobr></label><label id="devlangsMenuJScriptLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: JScript </nobr></label></span></td></tr></table><div id="devlangsMenu"><input id="VisualBasicCheckbox" type="checkbox" data="VisualBasic,vb,'persist'" value="on" onclick="SetLanguage(this)" /><label class="checkboxLabel" for="VisualBasicCheckbox">Visual Basic</label><br /><input id="CSharpCheckbox" type="checkbox" data="CSharp,cs,'persist'" value="on" onclick="SetLanguage(this)" /><label class="checkboxLabel" for="CSharpCheckbox">C#</label><br /><input id="ManagedCPlusPlusCheckbox" type="checkbox" data="ManagedCPlusPlus,cpp,'persist'" value="on" onclick="SetLanguage(this)" /><label class="checkboxLabel" for="ManagedCPlusPlusCheckbox">Visual C++</label><br /><input id="FSharpCheckbox" type="checkbox" data="FSharp,fs,'persist'" value="on" onclick="SetLanguage(this)" /><label class="checkboxLabel" for="FSharpCheckbox">F#</label><br /><input id="HLSLCheckbox" type="checkbox" data="HLSL,cpp,'persist'" value="on" onclick="SetLanguage(this)" /><label class="checkboxLabel" for="HLSLCheckbox">HLSL</label><br /><input id="JScriptCheckbox" type="checkbox" data="JScript,cs,'persist'" value="on" onclick="SetLanguage(this)" /><label class="checkboxLabel" for="JScriptCheckbox">JScript</label><br /></div><table id="bottomTable" cellpadding="0" cellspacing="0"><tr id="headerTableRow1"><td align="left"><span id="runningHeaderText">JavaScript</span></td></tr><tr id="headerTableRow2"><td align="left"><span id="nsrTitle">trim Method (String) (JavaScript)</span></td></tr><tr id="headerTableRow3"><td align="left"><a href="#exampleToggle" onclick="OpenSection(exampleToggle)">Example</a>  <a href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a> 
<span id="headfeedbackarea" class="feedbackhead">
<a href="javascript:SubmitFeedback('DevDocs@Microsoft.com','','','','8.0.13105.10000','%0\dThank%20you%20for%20your%20feedback.%20The%20developer%20writing%20teams%20use%20your%20feedback%20to%20improve%20documentation.%20While%20we%20are%20reviewing%20your%20feedback,%20we%20may%20send%20you%20e-mail%20to%20ask%20for%20clarification%20or%20feedback%20on%20a%20solution.%20We%20do%20not%20use%20your%20e-mail%20address%20for%20any%20other%20purpose%20and%20we%20delete%20it%20after%20we%20finish%20our%20review.%0\AFor%20further%20information%20about%20the%20privacy%20policies%20of%20Microsoft,%20please%20see%20http://privacy.microsoft.com/en-us/default.aspx.%0\A%0\d','Customer%20Feedback');">
Send Feedback
</a>
</span>
</td></tr></table><table id="gradientTable"><tr><td class="nsrBottom" background="../icons/gradient.gif" /></tr></table></div><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()" /><font color="DarkGray"><p /></font> <div class="introduction"><p xmlns:util="util">Removes the leading and trailing white space and line terminator characters from a string.</p></div><div id="syntaxSection" class="section"><div id="syntaxCodeBlocks" class="code"><span codelanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left" /></tr><tr><td><pre><span class="parameter" sdata="paramReference" xmlns:util="util">stringObj</span>.trim()</pre></td></tr></table></span></div></div><h1 class="heading"><span onclick="ExpandCollapse(sectionToggle0)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(sectionToggle0, event)" tabindex="0"><img id="sectionToggle0" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />Parameters</span></h1><div id="sectionSection0" class="section" name="collapseableSection" style="" expanded="true"><dl class="authored"><dt><span class="parameter" sdata="paramReference" xmlns:util="util">stringObj</span></dt><dd><p xmlns:util="util">Required. A <span sdata="langKeyword" value="String"><span class="keyword">String</span></span> object or string literal. This string is not modified by the <b>trim</b> method. </p></dd></dl></div><h1 class="heading"><span onclick="ExpandCollapse(returnValueToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(returnValueToggle, event)" tabindex="0"><img id="returnValueToggle" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />Return Value</span></h1><div id="returnValueSection" class="section" name="collapseableSection" style=""><p xmlns:util="util">The original string with leading and trailing white space and line terminator characters removed.</p></div><h1 class="heading"><span onclick="ExpandCollapse(languageReferenceRemarksToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(languageReferenceRemarksToggle, event)" tabindex="0"><img id="languageReferenceRemarksToggle" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />Remarks</span></h1><div id="languageReferenceRemarksSection" class="section" name="collapseableSection" style=""><p xmlns:util="util">The characters that are removed include space, tab, form feed, carriage return, and line feed. See <span sdata="link"><mshelp:link keywords="3b38b1bd-1f0f-4748-b13e-55cab36fd126" tabindex="0">Special Characters (Windows Scripting - JScript)</mshelp:link></span> for a comprehensive list of white space and line terminator characters.</p><p xmlns:util="util">For an example that shows how to implement your own trim method, see <span sdata="link"><mshelp:link keywords="1e1d0631-2a9f-4011-b9fe-fa338e1ef34c" tabindex="0">Prototypes and Prototype Inheritance</mshelp:link></span>.</p></div><h1 class="heading"><span onclick="ExpandCollapse(exampleToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(exampleToggle, event)" tabindex="0"><img id="exampleToggle" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />Example</span></h1><div id="exampleSection" class="section" name="collapseableSection" style=""><p xmlns:util="util">The following example illustrates the use of the <b>trim</b> method.</p><div class="code"><span codelanguage="JavaScript"><table width="100%" cellspacing="0" cellpadding="0"><tr><th>JavaScript </th><th><span class="copyCode" onclick="CopyCode(this)" onkeypress="CopyCode_CheckKey(this, event)" onmouseover="ChangeCopyCodeIcon(this)" onmouseout="ChangeCopyCodeIcon(this)" tabindex="0"><img class="copyCodeImage" name="ccImage" align="absmiddle" alt="Copy image" title="Copy image" src="../icons/copycode.gif" />Copy Code</span></th></tr><tr><td colspan="2"><pre>var message = " abc def \r\n ";
document.write("[" + message.trim() + "]");
document.write("<br/>");
document.write("length: " + message.trim().length);
// Output:
// [abc def]
// length: 7</pre></td></tr></table></span></div></div><h1 class="heading"><span onclick="ExpandCollapse(requirementsTitleToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(requirementsTitleToggle, event)" tabindex="0"><img id="requirementsTitleToggle" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />Requirements</span></h1><div id="requirementsTitleSection" class="section" name="collapseableSection" style=""><p xmlns:util="util">
</p><p>Supported in the following document modes: Internet Explorer 9 standards and Internet Explorer 10 standards. Also supported in Windows Store apps. See <mshelp:link keywords="440f4924-f7a9-48e0-873e-bd599a93b437" tabindex="0">Version Information</mshelp:link>.</p>
<p>Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards. </p>
</div><h1 class="heading"><span onclick="ExpandCollapse(seeAlsoToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(seeAlsoToggle, event)" tabindex="0"><img id="seeAlsoToggle" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />See Also</span></h1><div id="seeAlsoSection" class="section" name="collapseableSection" style=""><h4 class="subHeading">Other Resources</h4><div class="seeAlsoStyle"><span sdata="link" xmlns:util="util"><mshelp:link keywords="3b38b1bd-1f0f-4748-b13e-55cab36fd126" tabindex="0">Special Characters (Windows Scripting - JScript)</mshelp:link></span></div><div class="seeAlsoStyle"><span sdata="link" xmlns:util="util"><a href="8063ecd5-5778-4e87-b985-b21420171914.htm">String Object (JavaScript)</a></span></div></div></div><div id="footer"><div class="footerLine"><img width="100%" height="3px" src="../icons/footer.gif" alt="Footer image" title="Footer image" /></div>
<span id="feedbackarea">
Send
<a href="javascript:SubmitFeedback('DevDocs@Microsoft.com','','','','8.0.13105.10000','%0\dThank%20you%20for%20your%20feedback.%20The%20developer%20writing%20teams%20use%20your%20feedback%20to%20improve%20documentation.%20While%20we%20are%20reviewing%20your%20feedback,%20we%20may%20send%20you%20e-mail%20to%20ask%20for%20clarification%20or%20feedback%20on%20a%20solution.%20We%20do%20not%20use%20your%20e-mail%20address%20for%20any%20other%20purpose%20and%20we%20delete%20it%20after%20we%20finish%20our%20review.%0\AFor%20further%20information%20about%20the%20privacy%20policies%20of%20Microsoft,%20please%20see%20http://privacy.microsoft.com/en-us/default.aspx.%0\A%0\d','Customer%20Feedback');">
feedback
</a>
on this topic to Microsoft.
</span>
</div></div></body></html>