- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 05:20 PM
Hello,
I have a string contains "abc\1234"
I would like to extract from the back slash and get the number only such as "1234"
Can someone please help? Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 11:43 PM
@Annie10 Please continue to use double back slashes, generally \ has a special meaning example: \n is for the next line and hence scripting languages doesn't allow you to type one single backslash and to cut the meaning of backslash you have to use double slashes.
Conclusion is \\ is equivalent of \ in a string.
Please use the same line of code and it should work fine.
return source.u_name.slice(source.u_name.indexOf('\\')+1);
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 05:54 AM
Can you please try this?
return source.u_name.slice(source.u_name.indexOf('\\')+1);
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 11:07 PM
Hi @Arun_S1
I was able to get it to work by using the following:
return source.u_name.toString().substr(5, 6)
Thank you for helping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 06:06 AM
I see that you have hardcoded the start and the end positions, what happens if the format changes a little, better use the indexOf function to identify the start parameter and the length of the string and then pass them in the sbustr function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 07:11 AM
Thank you for your suggestion @Arun_S1
The original string contains only 1 back slash like this: "abc\1234"
Your code is looking for double back slashes. I tried to remove 1 back slash from the code, but that did not work.
return source.u_name.slice(source.u_name.indexOf('\\')+1);
Any advise?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 11:43 PM
@Annie10 Please continue to use double back slashes, generally \ has a special meaning example: \n is for the next line and hence scripting languages doesn't allow you to type one single backslash and to cut the meaning of backslash you have to use double slashes.
Conclusion is \\ is equivalent of \ in a string.
Please use the same line of code and it should work fine.
return source.u_name.slice(source.u_name.indexOf('\\')+1);
Thanks!!