?
Solved

splitting variable before any special character

Posted on 2013-05-14
1
Medium Priority
?
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

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

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
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

770 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