JavaScript split string with backslash
问题 I get from server some path like that: \some\some\some\some\mainSome And for display it to front, I need only last path(mainSome). And try to split it, but I can't. const path = '\some\some\some\some\mainSome'.split('\') //And also tried const path = '\some\some\some\some\mainSome'.split('\\') And this didn't work. Waiting for help from you 回答1: try this String.raw`\some\some\some\some\mainSome\`.split("\\"); 回答2: It's actually escaping the s s and m s in the string - you need to have a