0

I have an element in my dataframe which I want to modify. I have a column with the following type of values

https://mns-xyz-eu.abc.com/ccs/proposal?action=view&proposalId=12345

I want to replace the entire string with just the last 5 characters (i.e) Replace the entire character string with 12345 in this case.

How do I achieve this? Thanks a lot.

jack ryan
  • 61
  • 7

1 Answers1

0

One option is using a positive look behind using stringr::str_extract

str_extrct('https://mns-xyz-eu.abc.com/ccs/proposal?action=view&proposalId=12345', 
           '(?<=proposalId\\=)\\d+')
#Simple option
str_extract('https://mns-xyz-eu.abc.com/ccs/proposal?action=view&proposalId=12345', '\\d+')
A. Suliman
  • 12,923
  • 5
  • 24
  • 37