I am looking to create a system which on signup will create a subdomain on my website for the users account area.
Cisco Certified Network Associate Exam,640-802 CCNA All Answers ~100/100. Daily update
Cisco Certified Network Associate Exam,640-802 CCNA All Answers ~100/100. Daily update
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!
Try
ReplyDeleteval.split(/@|#/g);
The | is the regex equivalent of or. The g flag makes the expression match globally (ie all instances)
See this fiddle
As Pointy notes the g flag isn't necessary here. It is however necessary if wanting to find all matches within a string in JS regular expressions.
you could do
ReplyDeletefunction split(val) {
return val.split(/[@#]/g);
}