'How to replace " into space or delete first and last symbol?
I get xml data and I get value from it.
I need to delete symbols [ and ]
Here is my code, that gives me error about undegined variable:
@xml = XmlSimple.xml_in(res.content)//here I get xml document
payKey = @xml["payKey"]//gere I get needed value
//it looks like "[some character]" so I need to delete [ and ]
//I tried
payKey = @xml["payKey"].to_s()//to use tr method
payKey = payKey.tr("[]", "")//replacing
redirect_to "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay?cmd=_ap-payment&paykey=#{paykey}"//inserting into url
and result:
svcs.sandbox.paypal.com/AdaptivePayments/Pay?cmd=_ap-payment&paykey="AP-7NK73769LH704515X"
So I need to delete " signs. Can someone help me ?
Solution 1:[1]
My answer:
payKey = payKey[1..20]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | vinzee |