?
Solved

splitting variable before any special character

Posted on 2013-05-14
1
Medium Priority
?
277 Views
Last Modified: 2013-05-14
Hi,

I am reading in some data-params into a form and there is one hidden field that I need to populate that requires the data-param value to be stripped before any special characters.
So if the data-param value = 'Harry & Sally' then I would need to populate the hidden field with 'Harry '

Is there a way to split the value before any special character other than spaces?

Thanks
0
Comment
Question by:Al4ddin2
1 Comment
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39164843
var str = 'Harry & Sally';
var harry = str.split(/[^a-z0-9\s]/i)[0];
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question