Javascript regex to remove hex bytes?

One way is to have 255 bytes:

function removeHex(txt) {
   // Assume I have all of them
   return String(txt).replace(/[\x00\x01\x02\x03\xFF]/g, '')
}

removeHex('[\xaa] [\xff]')
>>> '[ยช] []'

What’s a simpler way to match those literal hex bytes?

82 thoughts on “Javascript regex to remove hex bytes?”

  1. Today, I went to the beachfront with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She
    placed the shell to her ear and screamed. There was a hermit crab inside
    and it pinched her ear. She never wants to go back! LoL
    I know this is completely off topic but I had to
    tell someone! https://www.herpessymptomsinmen.org/where-to-buy-hydroxychloroquine/

    Reply