I am new to Ruby and currently I am trying to take out a part from the http request string.
Request :
POST /test/userRegistration?id=1234&name=John&address=UK
Is there any way to take out "name=John&"
using slice
, gsub
or any other method ?
Output should be POST /test/userRegistration?id=1234&address=UK
Note : The value of "name" parameter can be different every time
Thanks
Try this ...
str = "POST /test/userRegistration?id=1234&name=John&address=UK"
str = str.sub(/&name=.+&/, '&')
str
=> "POST /test/userRegistration?id=1234&address=UK"