473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

smart split()

I am trying to create a function that parses a string and creates an array with the values which will be seperated by either white space or and unknown number of carriage returns/linebreaks....

I was trying something along these lines:

Expand|Select|Wrap|Line Numbers
  1. function processFactors(){
  2. var factors = new Array();
  3. var factors_in = document.form1.factors_in.value;
  4. factors_in = factors_in.replace(/\r\n|\r|\n/g, ' ');
  5. factors = factors_in.split(' ');
  6. }
  7.  
But that only works for a single return or white space...
I need some kind of loop that parses the string but I don't know the proper syntax...Any advice or thoughts are greatly appreciated!


thank you.
Mar 26 '07 #1
2 1405
k figured it out...!
seems to work all right.


function processFactors(){
var factors = new Array();
var factors_in = document.form1.factors_in.value;
factors_in = factors_in.replace(/\r\n|\r|\n/g, ' ');
factors = factors_in.split(' ');
var factorsList = new Array();
var c = 0;
for (var i =0; i<factors.length; i++){
if (factors[i] > ""){
factorsList[c] = factors[i];
c++;
}
}
Mar 26 '07 #2
mrhoo
428 256MB
var factors_in = document.form1.factors_in.value;
factors = factors_in.split(/\s+/);
Mar 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mathias Mamsch | last post by:
Hi, I got a text with about 1 million words where I want to count words and put them sorted to a list like " list = " I think there are at about 10% (about 100.000) different words in the...
14
by: David B. Held | last post by:
I wanted to post this proposal on c.l.c++.m, but my news server apparently does not support that group any more. I propose a new class of exception safety known as the "smart guarantee". ...
27
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined...
8
by: Axter | last post by:
I normally use a program call Doxygen to document my source code.(http://www.stack.nl/~dimitri/doxygen) This method works great for small and medium size projects, and you can get good...
92
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers,...
21
by: Raj | last post by:
Hi, We just executed a project with Python using TG. The feedback was to use more python like programming rather than C style code executed in Python. The feedback is from a Python purist and...
33
by: Ney André de Mello Zunino | last post by:
Hello. I have written a simple reference-counting smart pointer class template called RefCountPtr<T>. It works in conjunction with another class, ReferenceCountable, which is responsible for the...
54
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining...
50
by: Juha Nieminen | last post by:
I asked a long time ago in this group how to make a smart pointer which works with incomplete types. I got this answer (only relevant parts included): ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.