# lastIndexOf slash?

**URL:** <https://forum.kirupa.com/t/lastindexof-slash/64788>\
**Category:** Uncategorized\
**Created:** [September 20, 2004, 2:02am UTC](https://forum.kirupa.com/t/lastindexof-slash/64788 "2004-09-20T02:02:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uli](https://avatars.discourse-cdn.com/v4/letter/u/ccd318/32.png) [@Uli](https://forum.kirupa.com/u/Uli)\
**Post date:** [September 20, 2004, 2:02am UTC](https://forum.kirupa.com/t/lastindexof-slash/64788/1 "2004-09-20T02:02:51Z")

</div>

Hello,

Im trying to use the lastIndexOf function to discover where the last “” is located in my string… It seems to have a pb with the \ symbol…  
I tried mystring.lastIndexOf(’""’) and every other possibleway, it always returns -1

Any ideas?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 2:19am UTC](https://forum.kirupa.com/t/lastindexof-slash/64788/2 "2004-09-20T02:19:46Z")

</div>

use “\” since it is used in combination with escape characers (like  
and ), it, itself, has to be escaped

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 2:21am UTC](https://forum.kirupa.com/t/lastindexof-slash/64788/3 "2004-09-20T02:21:31Z")

</div>

Ok i’ve found a way…  
heh = String.fromCharCode(92);  
lastslashpos = myvar.lastIndexOf(heh);  
That seems to work with the ascii code…

Thanks for your reply tho

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 8:47am UTC](https://forum.kirupa.com/t/lastindexof-slash/64788/4 "2004-09-20T08:47:43Z")

</div>

senocular’s ver is simpler ?

lastslashpos = myvar.lastIndexOf("\");
