Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] How do I refer to whitespace characters?


  • From: javascript@xxxxxxxxxx (Dan Costea)
  • Subject: [Javascript] How do I refer to whitespace characters?
  • Date: Fri, 26 Apr 2002 10:52:22 -0700

You can use a RegExp (regular expression) like this /\s+/. This will do.

Example:

var s = "             asdf'  sadfAS  ";
alert ("->" + s + "<-\n->" + s.replace (/\s+/, "") + "<-");


Dan.



----- Original Message ----- 
From: "Lau" <lau@xxxxxxxxxxxxxxxx>
To: <javascript@xxxxxxxxxx>
Sent: Thursday, April 25, 2002 10:02 PM
Subject: [Javascript] How do I refer to whitespace characters?


> I want to read a string and remove all the whitespace before a word.
> How do I refer to tabs and newline characters etc.
> Can anyone give me a full list of what I should be checking for? 
> 
> 
> while(mystr.length>0 && mystr.charAt(0)==" ") 
>      mystr= mystr.substr(1);
> 
> 
> Peace
> Lau
> 
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> https://lists.LaTech.edu/mailman/listinfo/javascript