Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace "/?" from string

Tags:

regex

r

I am trying to replace "/?" by "?" in the following URL with R :

http://www-03.ibm.com/systems/fr/express/offerings/systemx_intel/?cmp=333AD&c

So it will become :

http://www-03.ibm.com/systems/fr/express/offerings/systemx_intel?cmp=333AD&c

I have tried different functions to replace it (str_replace_all, ...) but I have always the same issue, it cannot find the string "/?" because it is two special characters.

like image 425
user2506015 Avatar asked Sep 05 '26 07:09

user2506015


1 Answers

This is how to use the regex replacement function sub in this case:

x <- 'http://www-03.ibm.com/systems/fr/express/offerings/systemx_intel/?cmp=333AD&c'
sub('/\\?','?',x)
like image 105
Sam Mason Avatar answered Sep 07 '26 23:09

Sam Mason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!