Reputation: 726
I'm trying to split the string in to two strings
INPUT: "ASSO|ASSOCS|AS|ASSOCIATES/ASSOC/"
OUTPUT: "ASSO|ASSOCS|AS|ASSOCIATES","ASSOC"
Tried :
I tried removing the the last character "/"
first and replaced the other with ","
. Wanted to know can we do this both steps in once using regex
str=str.replace(/\/$/, "")
str=str.replace(\/,",")
Upvotes: 0
Views: 59
Reputation: 3185
If you are "trying to split the string in to two strings", then you could do
s = "ASSO|ASSOCS|AS|ASSOCIATES/ASSOC/"
s1, s2, _ = s.split('/')
Upvotes: 1