0

I've a strings with the values like:

share__43 share__153 share share_section

How do I get the integer values like 43 or 153?

1
  • 2
    You have a string or you have multiple strings? Is it one string with space separated parts or four separate strings? Commented Oct 7, 2013 at 9:49

2 Answers 2

2

Try this

var regex = new RegExp(/([0-9]+)/g);
var test = "share__43 share__153 share share_section";

var match = regex.exec(test);
alert('Found: ' + match[1]);

Fiddle

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

2 Comments

too long for a simple action
@Steve What does that even mean? What are you trying to do exactly?
1

Example, currently using a single string

var regex = /\d+/;
var str = "share__43";
alert (str.match(regex ));

Demo

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.