Handling forward slash in text

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2014 06:22 AM
I have an if statement where if (report == "string" || report == "string with forward slash in the middle of it). If the first item is selected with just a string it evaluates correctly but the one with the forward slash in the string fails. How do I handle this?
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2014 07:13 AM
When you are messing with \ you will need to use two because it is the escape character. This however is the backslash.
Try something like this;
//If you value is "String\Test"
if(report == "String\\Test"){
//matches against String\Test
}
If I have this all wrong, post your actual if statement and the value you're trying to match.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2014 07:18 AM
Its a forward slash "string/test". Adding two "sting//test" did not work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2014 07:49 AM
You should not have to escape forward slashes but try matching against, "string\/test".

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2014 10:00 AM
That did not work either