Quantcast
Channel: Regex for matching data between parenthesis BUT with a pattern to match inside - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Ryszard Czech for Regex for matching data between parenthesis BUT with a pattern to match inside

$
0
0

Use

\(([^()]*\bcm\b[^()]*)\)

See proof

Explanation

--------------------------------------------------------------------------------  \(                       '('--------------------------------------------------------------------------------  (                        group and capture to \1:--------------------------------------------------------------------------------    [^()]*                   any character except: '(', ')' (0 or                             more times (matching the most amount                             possible))--------------------------------------------------------------------------------    \b                       the boundary between a word char (\w)                             and something that is not a word char--------------------------------------------------------------------------------    cm                       'cm'--------------------------------------------------------------------------------    \b                       the boundary between a word char (\w)                             and something that is not a word char--------------------------------------------------------------------------------    [^()]*                   any character except: '(', ')' (0 or                             more times (matching the most amount                             possible))--------------------------------------------------------------------------------  )                        end of \1--------------------------------------------------------------------------------  \)                       ')'

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>