Position of character in a string

Posted by Irfan on Stack Overflow See other posts from Stack Overflow or by Irfan
Published on 2013-07-02T05:03:22Z Indexed on 2013/07/02 5:05 UTC
Read the original article Hit count: 212

Filed under:

I have a string :

var str = "12345a45";//position is 6 here

now i want the position of 'a'(alphabet) in that string similarly i have few more string like this:

var  str1 = "1234567a45";//position is 8 here
var str2 = "12345a4";//position is 6 here
var str3 = "123a";//position is 4 here
var str4 = "a45";//position is 1 here

Now what i thought of doing is , just searching the string from last and know the occurrence of any alphabet in that strings.

any help will be appreciated . thanks.

© Stack Overflow or respective owner

Related posts about JavaScript