开发者

How to replace part of string using regex

I want to replace all the :

xmlns="http://xml.blablabla"

and

 xmlns:something="xxx开发者_C百科x"

for a white space from a string.

Thanks


str.sub!(/xmlns=.+?"/, ' ')


String#sub is your friend:

my_string = '<Fare_MasterPricerCalendarReply xmlns="http://xml.blablabla">'
my_string.sub(/\s.+$/, " >")
# => "<Fare_MasterPricerCalendarReply >"


Use this regex: xmlns="[^"]*", it matches xmlns="http://xml.blablabla", then replace match with empty string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜