Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have a string something like this 1006 / HKD-undefined-000002 format and I also need both of it part sometime I need the right and then left one. But I dont know how to call in JS.
No need for RegEx, a little split() method should work:
RegEx
split()
var str = '1006 / HKD-undefined-000002'; if(str.indexOf('/') > -1) { var parts = str.split('/'); var firPart = parts[0]; var secPart = parts[1]; } else { console.log('No forward slash'); }
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.