I am trying to achieve the following for both @ or #.
function split(val) {
return val.split(/@/);
}
function extractLast(term) {
return split(term).pop();
}
Any help really appreciated!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try
The
|is the regex alternation operator ie ‘OR’. Thegflag makes the expression match globally (ie all instances)See this fiddle
As Pointy notes the
gflag isn’t necessary here. It is however necessary if wanting to find all matches within a string in JS regular expressions.