JavaScript Document (8) Events (8) ExtJS (9) Strings (3)
Exchange Links About this site Links to us 
|
General :: Web publishing :: JavaScript :: Strings
Articles:
This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Featured Article
How can I trim a string in JavaScript?Question: I need to trim a string from white space at the front and end. How can I do that elegantly?
Answer: Add the following string prototype function to your code. You will call it like predefined String member functions (such
as indexOf(), charAt() and Substring().
The code below shows the function declaration and how to use it.
This implementation of a trim() function uses two regular expressions to first replace the white space at the begiinning,
then the white space at the end of the string. White space in regular expressions is described as \s.
The beginning of the string is matched by ^ (see the first regex) and the end is matched by $ - in the second regex.
 | |  | |
<script language="JavaScript" type="text/javascript">
<!--
String.prototype.trim = function () {
return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
var s = new String(" Hello ");
s=s.trim();
alert("!" + s + "!");
</script>
| |  | |  |
|
| Most recent comments
2010-03-16 23:15:52:
by DOC
in Dating Scams
on Dating scammer Olga:
Darina (zelenka@progressivmail.net)
wedding of my sister.jpg
|
2010-03-16 22:13:15:
by DonaldTrumps
in Dating Scams
on Is this Russian girl scamming me? How to recognize scammers:
I have had emails from Margaret Asare, supposedly in Ghana. She is definitely a scammer. I have not been able to determine if the photos are of the scammer herself or if they are just stolen photos us ... read more
|
2010-03-16 22:12:05:
by anonymous
in Dating Scams
on Dating scammer Rhoda Naa from Accra, Ghana:
I have been in contact with this person. Name given Vida Odemety. As I suspected from the begining. I am looking to confirm. She told me she was a citizen of the United States. But then she needed an ... read more
|
2010-03-16 21:09:13:
by anonymous
in Dating Scams
on Dating scammer Amanda Smith from Ghana:
this girl is a scammer fake bitch from ghana fuckin scammers think we men are so stupid seems to be to real usually is!
|
2010-03-16 20:40:57:
by anonymous
in Dating Scams
on Scammer Jane Mabou from Ivory Coast, Africa:
mentiras. solo engaƱos.
|
2010-03-16 20:32:09:
by anonymous
in Dating Scams
on Dating scammer Danniella Adu from Ghana:
ive been bein scammed also and by a women name comfort yea well guess she lookin for soul mate from ghana ya like that all say i no they are really men behinde computers actin as women fuck that they ... read more
|
2010-03-16 20:10:21:
by venezolano
in Dating Scams
on Dating scammer Tatyana (photos: Raven Riley):
Nice pictures of porn star Raven Riley. She is neither Russian nor African. She is hakf breed with Italian and latino. Don't let pictures fool yourself.
|
2010-03-16 19:56:06:
by anonymous
in Dating Scams
on Dating scammer Alexandra from Kozmodemyansk:
These scammer are realy stupid, they don't even change the content their send, what they did just copy and send
|
2010-03-16 19:28:04:
by [hidden]
in Male Dating Scammers
on Dating scammer Alan Gipson:
hello ladys i sorry you got taken by this man I got taken to. he took my money and heart he promise he would come if i send mony. why do he do this?. i dont know. I wonder.? so he dont get more women ... read more
|
|
2010-03-16 19:19:48:
by Dirk
in Dating Scams
on Dating scammer Natalya from Osinniki, Russia:
[quote]Tatiana
tanya_angel
KishineMoldova[ /quote]
[r>[quote]Engli( Fluent)[/quote]
br>[quote]i want t found a good friend....maybe boyfriend, husbant- who will respect, supp ... read more
|
|