Get substring after backslash in a string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2013 09:37 AM
hi
I have a string that contains a backslash.I want the substring after backslash. How can i get it?I tried substring function but its not working.PLease help me out.
example if the string is "first\last" I want to store 'last' in a variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2013 09:51 AM
//say str contains the string
var lst = str.substr(str.indexOf('\\')+1);
gs.log(lst)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2013 06:56 PM
I checked this already,this is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2013 07:20 PM
you tried with double slash or a single slash? if you paste the script exactly, it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2013 10:42 PM
using you script -
var lst = str.substr(str.indexOf('\\')+1);
gs.log(lst)
take one example-
var str = "first\last";
var lst = str.substr(str.indexOf('\\')+1);
gs.log(lst) ;
it will give the result 'firstlast',But the result should be 'last'.