I have a simple string like this:
image[2]
I want to get the number between [], in this case have to return 2.
What is a good regular expression to do this in JavaScript? I have tried with substring but I want to apply a regular expression.
You can use
This returns
2as a number.