Reputation: 637
I have a string, for example testserver\sho007
, how do I use jQuery to return only sho007
?
Upvotes: 0
Views: 1397
Reputation: 5000
You can do it simply with javascript
var my_string="testserver\sho007";
var left_side=my_string.split("\\")[0];
var right_side=my_string.split("\\")[1];
edited to add the double slash as Eric mentioned
Upvotes: 2
Reputation: 3246
split the string using "\" and get the position [1], always start with [0]
exp:
html:
<a class='test'>testserver\sho007</a>
js:
$(document).ready(function(){
var a = $(".test").text();
var aResult = a.split("\\")[1];
});
testserver = [0]
sho007 = [1]
Upvotes: 0
Reputation: 7163
Use Regular Expressions if you are sure that the text you want is going to be after the slash.
Upvotes: 0