0

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.

1 Answer 1

1

No need for RegEx, a little split() method should work:

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');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.