Regex get all content between two characters [closed]

I need to get content between symbols [ and ] even there are other same characters i need to take content between first [ and last ]. In jquery useing regex. Thanks Advance

Answers:

Answer

No need for jQuery, use standard Javascript :

var extract = str.match(/\[(.*)\]/).pop();

If your delimiters are { and }, change it to

var extract = str.match(/{(.*)}/).pop();
Answer

How about

yourStringVariable.match(/\[(.*)\]/)[1]

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.