You are just throwing any code you can find at the problem without trying to understand what it does.
You say you have a JavaScript book, yes?
So start with it. Start with Chapter 1. Read it. DO THE EXERCISES in the book.
None of your code so far has made ANY SENSE AT ALL. None.
In this latest effort, you have this:
Code:
var theRegExp = /[^a-z] +[\d]/;
Do you have ANY idea what that means???
It means "search for a string of this form:
-- Any character *except* a lowercase letter.
-- Followed by ONE OR MORE spaces
-- Followed by one digit.
And then you try to use that expression to SPLIT this string:
Code:
var StrData = "Sally,20,15.50,Mary,32,A";
But NO PLACE in that string is there ANY string of characters that match the regular expression! Because NO PLACE in that string is there a space, and you MUST have a space to match the expression!
Okay, let's get rid of the space. Let's change it to:
Code:
var theRegExp = /[^a-z][\d]/;
So that says "any character EXCEPT a lower case letter that is then followed by a digit".
So look at the possible split points in that string:
Code:
var StrData = "Sally[u],2</u>0[u],1</u>5[u].5</u>0,Mary[u],3</u>A";
Each of those [u]red underlined</u> pairs of characters matches the expression: "A character that is not a lower case letter and which is followed by a digit."
So when you finally SPLIT using that regular expression, you will have an ARRAY OF STRING with the following elements:
Code:
Sally
0
5
0,Mary
2,A
Because the SPLIT *removes* the characters that you do the split ON.
Does that even come CLOSE to what you are after???
Of course not.
So STOP just coding. FIRST think about what you need to do. Then come up with a PLAN. Then try to CODE the plan.
It doesn't do any good to throw random code at a problem. You will never solve the problem.
More than half of the work in programming is *NOT* coding. Most of the work is (a) defining the problem, (b) designing an approach to the solution, (c) designing a way you can test that your solution is the right one. Only then do you start the coding. ONLY THEN.