Re: [R] regex for "[2440810] / www.tinyurl.com/hgaco4fha3"

2018-02-20 Thread Bert Gunter
These are always kind of fun, not least because of the variety of different replies that "work" at least somewhat. Here's mine: > stringa <- "[2440810] / www.tinyurl.com/hgaco4fha3" > sub("^(.+)www\\.(.+)\\.com.+","\\1\\2",stringa) [1] "[2440810] / tinyurl" Note the use of doubled backslashes

Re: [R] regex for "[2440810] / www.tinyurl.com/hgaco4fha3"

2018-02-20 Thread Ulrik Stervbo
Hi Omar, you are almost there but! Your first substitution looks 'www' as the start of the line followed by anything (which then do nothing), so your second substitution removes everything from the first '.' to be found (which is the one after www). What you want to do is x <- "[2440810] /

[R] regex for "[2440810] / www.tinyurl.com/hgaco4fha3"

2018-02-20 Thread Omar André Gonzáles Díaz
Hi, I need help for cleaning this: "[2440810] / www.tinyurl.com/hgaco4fha3" My desired output is: "[2440810] / tinyurl". My attemps: stringa <- "[2440810] / www.tinyurl.com/hgaco4fha3" b <- sub('^www.', '', stringa) #wanted to get rid of "www." part. Until first dot. b <- sub('[.].*', '',