title: How to match a string with `\xXXXX` and `\uXXXX`
body: <p>I have a string that contains <code>\xXXXX</code> and <code>\uXXXX</code>:</p>
  
  <pre><code>str = "\nDefault\nRouterRandom=\x9Db\u0012\xD3,\x92r\xFC o\u007F\x9B+\u0005I`\nWebInit=1\n"
  </code></pre>
  
  <p>I want to delete the content: </p>
  
  <pre><code>"RouterRandom=\x9Db\u0012\xD3,\x92r\xFC o\u007F\x9B+\u0005I`\n"
  </code></pre>
  
  <p>How can I match the string or delete it? I tried:</p>
  
  <pre><code>content = str.sub(/RouterRandom=.*WebInit/, "")
  </code></pre>
  
  <p>It returns errors:</p>
  
  <pre><code>E:/Automation/experiment/ruby_test/string_test.rb:119:in `sub': invalid byte sequence in UTF-8 (ArgumentError)
  from E:/Automation/experiment/ruby_test/string_test.rb:119:in `block in &lt;top (required)&gt;'
  from E:/Automation/experiment/ruby_test/string_test.rb:110:in `open'
  from E:/Automation/experiment/ruby_test/string_test.rb:110:in `&lt;top (required)&gt;'
  from -e:1:in `load'
  from -e:1:in `&lt;main&gt;'
  </code></pre>