0

I want to replace all the :

xmlns="http://xml.blablabla"

and

 xmlns:something="xxxx"

for a white space from a string.

Thanks

3 Answers 3

2
str.sub!(/xmlns=.+?"/, ' ')
Sign up to request clarification or add additional context in comments.

1 Comment

This works, but only for the first occurrence... how can I make it for every occurrenceof the regex?
1

String#sub is your friend:

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

2 Comments

That erases everything in my string... =S
Yes, sorry... But @Radu answer helped.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.