Testing for characters in JS string
Moderator: General Moderators
Testing for characters in JS string
simple question using JavaScript, how can i determine if a string contains certain characters, eg qoutes or asterisks?
use regEx - yes, i know it's a fantastic pain in the b**t that you can even do them in JS, but hey: it's been certified as a good thing, even Bill Gates and Richard Stallman do the regEx-jiggle together.
Coming back to your question: use Javascript's search (don't have a link to a tutorial for that, but have a look at the following example)
Coming back to your question: use Javascript's search (don't have a link to a tutorial for that, but have a look at the following example)
Code: Select all
<html><head><title>Test</title>
</head><body>
<script type="text/javascript">
<!--
var Aussage = "Hello there, sky is blue, sun is bright, life is just like dynamite.";
var Ergebnis = Aussage.search(/dynamite.+/);
if(Ergebnis != -1)
alert("found");
//-->
</script>
</body></html>