Need to split the string

str = “0x22334455”
I need the output as 0x22 0x33 0x44 0x55

How do I use gsub for this example?

I’m not sure that you’re phrasing your output as what you really want,
but here’s how to get exactly that:

str[2…-1].gsub(/(\d{2})/,’ 0x\1’).strip
=> “0x22 0x33 0x44 0x55”