Link to home
Start Free TrialLog in
Avatar of mjarner
mjarner

asked on

Get content inside (brackets)

Hi

I am trying to make a javascript function that checks if the input containes brackets, and then use the content inside the brackets. The string should then be shortened and made into a number I can use to add another number.

Example:
input: test string(+100abc)
output: 100

Example 2:
input: anotherstring (+123.45abc)
output: 123.45

Thanks in advance!
SOLUTION
Avatar of davekok
davekok
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try below one.

var input = 'anotherstring (+123.45abc)';
var output = input.replace(/[^0-9\.]+/g, '');

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial