Vote 投票 1 1
How To trim() in Javascriptどのようにトリム( )はJavaScript
Angsuman ChakrabortyのAngsuman Chakraborty
March 17th, 2006 2006年3月17日 Javascript doesn’t natively support trim on strings. JavaScriptのトリムをネイティブではサポートされない文字列です。 It is however very easy to implement with regular expressions.しかしこれは非常に簡単に正規表現を実装する。
Filed under提出されて Headline Newsニュースの見出し , 、 How Toどのように , 、 Tech Note技術のノート , 、 Webウェブ | |
| |
RSS 2.0 RSS 2.0を | |
Email this Article電子メールこの記事
You may also like to readを読むようにすることも可能 |




January 20th, 2007 at 12:35 am 2007年1月20日の12:35時
Hi..こんにちは.. im new to javascript… first of all i want to know whether javascript and jscript is same..イム新しいをJavaScriptに…まず第一にしたいかどうかを知って、 JavaScriptとJScriptのは、同じ.. or any other difference… and plz guide me what is the use of trim function…またはその他の違い…とのplzガイドの使用をメイントリム機能は何です…
January 20th, 2007 at 12:36 am 2007年1月20日の12:36時
How to validate the forms in javascript… JavaScriptを検証するためのフォームをどのように…
February 9th, 2007 at 2:46 am 2007年2月9日の午前8:46
uday plese try to understand yarr, why ur try to javascruipt go to your bad and just sleeping yarr, edighotウダイplese yarrを理解して、なぜ出典しようとして悪いとjavascruiptに行くだけ眠ってyarr 、 edighot
July 18th, 2007 at 1:19 pm 2007年7月18日は午後8:19
// This function is for stripping leading and trailing spacesfunction trim(str) { if (str != null) { var i; for (i=0; i=0; i–) { if (str.charAt(i)!=” “) { str=str.substring(0,i+1); break; } } if (str.charAt(0)==” “) { return “”; } else { return str; } }} / /この関数は、末尾にリードをストリッピングspacesfunctionトリム( str ) (もし( str ! = nullが) ( var私;を(私= 0 ;私= 0 ;私- ) (もし( str.charat (私) ! = " " ) ( str = str.substring ( 0 、私+1 ) ;休憩; ) )の場合( str.charat ( 0 ) == " " ) (戻り" " ; )他(戻りstr ; ) ) )
August 1st, 2007 at 11:45 am 2007年8月1日は午前11時
this is my comment ok sorryこれは私のコメントしますごめん
November 15th, 2007 at 5:57 am 2007年11月15日は5:57アム
This should actually be as follows:これは実際には以下のとおり:
surname = surname.replace(/^\s+/, “”).replace(/\s+$/, “”);姓= surname.replace ( / ^ \秒+ / 、 " " ) 。置き換える( / \秒+ $ / 、 " " ) ;
December 5th, 2007 at 12:42 am 2007年12月5日の12:42時
function trim(str, chars) {関数トリム( str 、文字) (
return ltrim(rtrim(str, chars), chars);戻りltrim ( rtrim ( str 、文字) 、文字) ;
} )
function ltrim(str, chars) {関数ltrim ( str 、文字) (
chars = chars || “\\s”;文字=文字| | " \ \秒" ;
return str.replace(new RegExp(”^[" + chars + "]+”, “g”), “”);戻りstr.replace (新たな正規表現("^[" +文字+ "]+",の" g " ) 、 " " ) ;
} )
function rtrim(str, chars) {関数rtrim ( str 、文字) (
chars = chars || “\\s”;文字=文字| | " \ \秒" ;
return str.replace(new RegExp(”[" + chars + "]+$”, “g”), “”);戻りstr.replace (新たな正規表現( " [ " +文字+ "]+$",の" g " ) 、 " " ) ;
} )
March 31st, 2008 at 4:40 am 2008年3月31日4:40アム
To answer this..に答えるこの.. Javascript and Jscript are the same meaning with the different versioning. JavaScriptとJScriptのは、同じ意味の異なるバージョンです。 Jscript is the version of Microsoft javascript.のバージョンのMicrosoftのJScriptは、 JavaScriptのです。 Some time the Document Object Model might differ from the Javascript.いくつかの時間のドキュメントオブジェクトモデルが異なってJavaScriptです。 And Jscript works only on IE browser.とJScriptのブラウザでのみ動作します。
This might answer your question.このご質問に対する回答かもしれない。
http://javascript.about.com/library/bljscript.htm
Thanks for the trim code.トリムコードてくれてありがとう。
Thanks.ありがとう。
April 5th, 2008 at 8:18 am 2008年4月5日は午前8時18時
i want to search the javascript questions JavaScriptの質問を検索して欲しい
April 5th, 2008 at 8:22 am 2008年4月5日は午前8時22時
to know the java script books Javaスクリプト書籍を知っている
April 25th, 2008 at 2:16 am 2008年4月25日2:16 AMの
Can also implement a trim function by extending the string type using a prototype.を実施することもできます。トリム機能を拡張することにより文字列型のプロトタイプを使用しています。 Have a look atを見て http://whadiz.com/c/whatis.aspx/programming/javascript/javascript_trim