This article is based on the regular expression which returns a string
which is between parentheses. For example: I want to get the string
which resides between the strings "(" and ")"
I expect five hundred dollars ($500).would return $500So You need to create a set of escaped (with \ ) parentheses (that match the parentheses) and a group of regular parentheses that create your capturing group:var regExp = /\(([^)]+)\)/; var matches = regExp.exec("I expect five hundred dollars ($500)."); //matches[1] contains the value between the parentheses console.log(matches[1]);Breakdown:
|
Tuesday, February 27, 2018
Regular Expression to get a string between parentheses
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment