0

I want to get "North" and "6544789" strings separately from "North-6544789-Input.csv" by using Regex pattern. Could you please guide me to get Regex pattern for this string.

3
  • 1
    why not simply var items = 'North-6544789-Input.csv'.split("-") and item[0] is North and item[1] is 6544789 Commented May 10, 2016 at 6:18
  • Are there more such example with some complex pattern? If not, then the comment above has a simple answer for you. Commented May 10, 2016 at 6:19
  • Please don't use regex for simple strings like what you have, unless you are obliged to use it. Commented May 10, 2016 at 8:35

2 Answers 2

1

Do:

^([^-]+)-([^-]+)-.*

\1 is North, \2 is 6544789.

Demo

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for your quick response .You save my day!. :)
1

Simply try

var items = 'North-6544789-Input.csv'.split("-");

alert( "first item - " + items[0] ); 

alert( "second item - " + items[1] ); 

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.