Hi James,
I'm not sure I understand what you are tryring to do, but finding a character in a string can be easily done with the help of the substring() method.
Hi James,
I'm not sure I understand what you are tryring to do, but finding a character in a string can be easily done with the help of the substring() method.
Hey James,
Just to add the easiest way to find if a character is present in a string is String.indexOf(); https://developer.mozilla.org/en-US/...String/indexOf
E.g.
For your specific question I'm also not sure what you're asking exactly.Code:let exampleString = "This is a string with a backslash \\"; //This evaluates to true as there is a backslash. if(exampleString.indexOf("\\") > -1) { }
Thank you. I will try out your suggestions.
I think that both of your examples have pointed me in the right direction. If it works I will post the solution. The script I am working on updating is a simple gallery script with a few buttons that allows my to cycle through images.
Here is one of the examples listed on the PHP page for strpos. What I am/was looking for is the javascript equivalent of that.
PHP Code:
<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// The !== operator can also be used. Using != would not work as expected
// because the position of 'a' is 0. The statement (0 != false) evaluates
// to false.
if ($pos !== false) {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
} else {
echo "The string '$findme' was not found in the string '$mystring'";
}
?>
To choose the lesser of two evils is still to choose evil. My personal site
Got it. I replaced
withCode:function newio(n){ newio.Num += n || -newio.Num; newio.Num = newio.Num < 0? newio.count - 1 : newio.Num % newio.count; newio.imgo.src = '/images/screenshots/' + newio.ar[newio.Num]; newio.output.value = newio.ar[newio.Num]; return false; }
Code:function newio(n){ newio.Num += n || -newio.Num; newio.Num = newio.Num < 0? newio.count - 1 : newio.Num % newio.count; var n=newio.ar[newio.Num]; var n = n.search("/"); if (n<0) { newio.imgo.src = '/images/screenshots/' + newio.ar[newio.Num]; } else { newio.imgo.src=newio.ar[newio.Num]; } newio.output.value = newio.ar[newio.Num]; return false; }
To choose the lesser of two evils is still to choose evil. My personal site
Bookmarks