I have a search box. I need to remove all the special characters from the search term and then query it. “’-,?~!@#$%&*+-= all these characters.... can anybody suggest a proper regular expression for this ? and the syntax for using it in javascript.
my query is saved in var query;
Jayakrishnan_gk
0
Newbie Poster
Recommended Answers
Jump to PostYou can replace strings doing so:
<script type="text/javascript"> var query="Wat is the question?"; query = query.replace(/?/, ""); </script>
Visit http://www.w3schools.com/jsref/jsref_replace.asp for more information
~G
Jump to PostYou can create a regular expression like the one in the variable called myRegExPattern to match any character listed between the square brackets. The square brackets define a "character class" aka "character set". Then replace each character that is matched.
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- Hide from browsers …
All 7 Replies
Graphix
68
---
Jayakrishnan_gk
0
Newbie Poster
d5e5
109
Master Poster
Jayakrishnan_gk
0
Newbie Poster
d5e5
109
Master Poster
d5e5
109
Master Poster
Jayakrishnan_gk
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.