0

I'm trying to do this regex :

([A-Za-z]+\\s*?)+\\-+\\s+\\$[0-9.]+")

Searching for pattern like:

Text Text2- $566.767 Text3 Text4- $7886.765 ...continues

Here is the code I used:

data_out <- data[,unlist(lapply(col,function(x) {str_extract_all(x,"([A-Za-z]+\\s*?)+\\-+\\s+\\$[0-9.]+")})),id]

The above code works fine, but it takes very long to execute.

Is there any faster way to extract the above pattern?

Expected input and output shown in below screen shot :

Sample Input and expected output screenshot

Mradul.J
  • 1
  • 1
  • 2
    Welcome to StackOverflow! Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269). This will make it much easier for others to help you. – Sotos Aug 10 '17 at 08:08
  • Your code doesn't extract anything in my end, An example (and desired output) would be nice. – ekstroem Aug 10 '17 at 20:30
  • @ekstroem **Input** `id col 1 Abncv Dtyiuy- $876.879 Gtyut Dkjh- $98.765 2 Bsgf Cjhgf- $76.89 Gtsdjh Dkfgg/sdfjhg sdjgh- $9438.765 Iuywer Isdhgf- $874.654` **output** `id col 1 Abncv Dtyiuy- $876.879 1 Gtyut Dkjh- $98.765 2 Bsgf Cjhgf- $76.89 2 Gtsdjh Dkfgg/sdfjhg sdjgh- $9438.765 2 Iuywer Isdhgf- $874.654' – Mradul.J Aug 11 '17 at 09:47
  • Please update the question with the information provided in R code so we are sure to get the structure right. – ekstroem Aug 11 '17 at 09:52
  • @ekstroem : Attached screenshot for input and expected output – Mradul.J Aug 11 '17 at 12:51

0 Answers0