Search code examples
rparentheses

How to add parentheses between numbers? I know how to add dashes, are they doing the same way?


how to add parentheses between numbers? I know how to add dashes, are they doing the same way? like 123456789 to (123)456789 in R programming?


Solution

  • sub("(\\d{3})", "(\\1)", 123456789)
    [1] "(123)456789"