gsub(pattern = "(S[^/]{0,}/.)([:space:]{0,})([0-9,]{0,})(\n){0,}",replace="", 
TV_Precios2)

-----Original Message-----
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Omar André 
Gonzáles Díaz
Sent: Tuesday, September 29, 2015 11:31 AM
To: r-help@R-project.org
Subject: [R] Fwd: Regex: just keep the money and not the description

Excuse me, here is the vector:

TV_Precios2 <- c("S/. 2,499.00S/. 1,999.00", "S/. 2,299.00  S/.
1,599.00", "S/. 2,299.00  S/. 1,599.00", "S 40\" FULL HD 40LF6350S/. 
1,999.00S/. 1,699.00", "S/. 5,999.00S/. 4,799.00", "S/. 3,499.00S/. 2,999.00", 
"S/. 4,799.00S/. 3,699.00", "S/. 599.00", "S/. 1,299.00", "S/. 999.00  S/. 
799.00", "S/. 1,999.00  S/. 1,699.00", "S/. 999.00  S/. 849.00", "S/. 499.00  
S/. 439.00", "S610S/. 1,899.00", "S/. 1,799.00S/. 1,699.00", "S/. 2,299.00S/. 
1,699.00", "S/.
8,999.00S/. 7,299.00",
"S9000S/. 10,999.00S/. 8,999.00", "S9000S/. 14,999.00S/. 12,999.00", "S/. 
6,999.00S/. 5,999.00", "S/. 2,799.00S/. 2,299.00", "S/.
2,999.00S/. 2,649.00",
"SMART 49LF5900S/. 2,399.00S/. 2,149.00", "S/. 2,299.00  S/. 1,599.00"
)

---------- Forwarded message ----------
From: Omar André Gonzáles Díaz <oma.gonza...@gmail.com>
Date: 2015-09-29 10:24 GMT-05:00
Subject: Regex: just keep the money and not the description
To: "r-help@R-project.org" <r-help@r-project.org>


Hi R users, I have a character vector with 2 numbers: old price, new price. The 
problem is that some rows (4,23, for example) contain a little description of 
the product, which I don't need.

I've tried a lot of thins, like this one:

TV_Precios3 <- gsub("^S ^[0-9]{2}\\$","",TV_Precios2)

Without result. Any help is welcome.

After that I want to separate them with colsplit (have this solved) based on 
"S/.".



head(TV_Precios3,50)
 [1] "S/. 2,499.00S/. 1,999.00"
 [2] "S/. 2,299.00  S/. 1,599.00"
 [3] "S/. 2,299.00  S/. 1,599.00"
 [4] "S 40\" FULL HD 40LF6350S/. 1,999.00S/. 1,699.00"
 [5] "S/. 5,999.00S/. 4,799.00"
 [6] "S/. 3,499.00S/. 2,999.00"
 [7] "S/. 4,799.00S/. 3,699.00"
 [8] "S/. 599.00"
 [9] "S/. 1,299.00"
[10] "S/. 999.00  S/. 799.00"
[11] "S/. 1,999.00  S/. 1,699.00"
[12] "S/. 999.00  S/. 849.00"
[13] "S/. 499.00  S/. 439.00"
[14] "S610S/. 1,899.00"
[15] "S/. 1,799.00S/. 1,699.00"
[16] "S/. 2,299.00S/. 1,699.00"
[17] "S/. 8,999.00S/. 7,299.00"
[18] "S9000S/. 10,999.00S/. 8,999.00"
[19] "S9000S/. 14,999.00S/. 12,999.00"
[20] "S/. 6,999.00S/. 5,999.00"
[21] "S/. 2,799.00S/. 2,299.00"
[22] "S/. 2,999.00S/. 2,649.00"
[23] "SMART 49LF5900S/. 2,399.00S/. 2,149.00"
[24] "S/. 2,299.00  S/. 1,599.00"

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Nothing in this message is intended to constitute an electronic signature 
unless a specific statement to the contrary is included in this message.

Confidentiality Note: This message is intended only for the person or entity to 
which it is addressed. It may contain confidential and/or privileged material. 
Any review, transmission, dissemination or other use, or taking of any action 
in reliance upon this message by persons or entities other than the intended 
recipient is prohibited and may be unlawful. If you received this message in 
error, please contact the sender and delete it from your computer.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to