Let\'s imagine you have a string:
strLine <- \"The transactions (on your account) were as follows: 0 3,000 (500) 0 2.25 (1,200)\"
Is the
Here's the base R way, for the sake of completeness...
x <- unlist(regmatches(strLine, gregexpr('\\(?[0-9,.]+', strLine))) x <- as.numeric(gsub('\\(', '-', gsub(',', '', x))) [1] 0.00 3000.00 -500.00 0.00 2.25 -1200.00