fork download
  1. r <- "(?(DEFINE)(?<n>[-+]?\\d+(?:\\.\\d+)?)(?<a>\\s*[-+*\\/]\\s*)(?<g>\\((?:(?&n)|(?&g))(?&a)(?:(?&n)|(?&g))\\)))^(?&g)$"
  2. x <- c("(14.0 + 46.0)", "((5.0 - 50.0) - 15.0)", "(15.0 - (5.0 - 50.0))", "(15.0 - (5.0 - 50.0)")
  3. grep(r, x, perl=TRUE)
Success #stdin #stdout 0.2s 39012KB
stdin
Standard input is empty
stdout
[1] 1 2 3