I have this string ffff @fgggg @
, How can I do substring last @, Thats mean When I am using this code:
String text = `ffff @fgggg @`;
selectedUser = text.substring();
I expect selectedUser be == "";
I want to check text from last @ ? If after last @
be nothing, substring()
method return "" ?
CodePudding user response:
try: selectedUser = text.split('@') is this what you mean?
CodePudding user response:
I found answer :
selectedUser = text.substring(text.lastIndexOf('@') 1);
and I got "". It checked from last @.