Exploding a string into an array in Javascript.

This script will take a string and explode it into an array. Neato huh?

In my project, I had one field in a form where the user would enter several email addresses seperated by semi-colon’s. I wanted to validate that each email address was valid, but first you have to seperate the long string.

function explodeArray(item,delimiter) {
tempArray=new Array(1);
var Count=0;
var tempString=new String(item);
while (tempString.indexOf(delimiter)>0) {
tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
Count=Count+1
}
tempArray[Count]=tempString;
return tempArray;
}

Published by theirishduck

I love the ability where I can plan, prioritise, design, develop and deliver blended learning solutions for a variety of markets. I love to consult and advise about the best use of digital learning and improve design standards in line with evolving ways of working. I also enjoy to keep up to date with, understand and regularly recommend emerging technologies and practice to improve individuals, teams and organisational capabilities. With over 12 years digital learning experience and demonstrated experience in both instructional design and eLearning development, I have also a lot of experience conducting training needs analysis including how to leverage principles such as design thinking and root cause analysis to understand and address performance gaps. I also have led many facilitation workshops and even presented at iDesignX and Game Developers Conferences both here in Australia, Wales and in the United States. I bring loads of coding experience in Java, ASM, C++, HTML, JavaScript, SCORM and xAPI, as well as proven capability using Adobe Captivate, Trivantis Lectora and Articulate Storyline 360 Studio authoring programs. Of course, Adobe Creative Cloud is also part of my toolbox which I also use daily. Being taught traditional and advanced 3D animation techniques, I love hand drawing and polymer clay sculpture, but can also use the Blender, 3D Studio Max, Maya and Softimage applications. With strong multimedia, training and programming backgrounds, I understand modern learner behaviour including micro and social learning, I am very familiar with most LMSes and app-based (XCode and Android Studio), adult learning models and e-solutions. I also possess the ability to manage multiple projects simultaneously, whilst being pro-active in delivering work independently with minimal supervision, but enjoy working in teams. I've been told I am a resilient, relationship focused guy which can manage and navigate conflicting views and stakeholders/subject matter experts.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: