title: Office.js wildcard search with special characters crashes Word Online but not installed MSWord
body: <p>Wildcard searches such as the example detailed in the following article crashes Word Online, whilst working as expected for the installed version of MSWord</p>
  
  <p><a href="https://docs.microsoft.com/en-us/office/dev/add-ins/word/search-option-guidance" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/office/dev/add-ins/word/search-option-guidance</a></p>
  
  <p>I'm searching for the following text:
  'Payment of invoices by Sponsor shall be made within thirty (30'</p>
  
  <p>The text may or may not be broken across line/section breaks.  Therefore I'm performing a wildcard search as follows:
  'Payment?of?invoices?by?Sponsor?shall?be?made?within?thirty?(30'</p>
  
  <p>This causes Word-Online to crash the browser.</p>
  
  <p>Interestingly the following works in both Word Online and MSWord:</p>
  
  <p>'Payment of invoices by Sponsor shall be made within thirty (30) days'</p>
  
  <p>'Payment?of?invoices?by?Sponsor?shall?be?made?within?thirty?(30)?days'</p>
  
  <p>There appears to be a problem with un-closed parenthesis in the wildcard expression.</p>
  
  <p>Following the article above, it suggests that the parenthesis should be escaped with square brackets.  The following worked in MSWord but crashed Word-Online:</p>
  
  <p>'Payment?of?invoices?by?Sponsor?shall?be?made?within?thirty?[(]30'</p>
  
  <p>Even stranger is that the square brackets escapement only works if the last character is being escaped.</p>
  
  <p>This works in both MSWord and Word-Online:</p>
  
  <p>'include?intangible?things?[(]'</p>
  
  <p>whereas this only works in MSWord and crashes Word-Online</p>
  
  <p>include?intangible?things?[(]e</p>
  
  <p>The example pattern in the article above ' [ * ] * ' crashes Word Online, whilst working as expected in MSWord.  </p>
  
  <pre><code>input = 'include?intangible?things?[(]e';
  const { Word } = window;
  Word.run(context =&gt; {
      const { body } = context.document;
      const searchResults = body.search(input, {
          matchCase: false,
          ignoreSpace: true,
          ignorePunct: true,
          matchWildcards: true
      });
      context.load(searchResults);
      return context
          .sync()
          .then(() =&gt; {
  
          })
          .catch(error =&gt; {            
          });
  });
  </code></pre>
  
  <p>Both MSWord and Word Online should behave the same when both are executed through the Office.js API.</p>
  
  <p>This looks like a bug in Word Online.  I would speculate that it's probably something to do with url encoding.</p>
  
  <p>Either that, or I'm not encoding my input pattern correctly when the target is Word Online.  In which case the article referenced above needs updating to detail what the Word Online 'escapes' are for the special characters.</p>
  
  <p>Curiously the escaping [ ] brackets are themselves special characters.</p>
  
  <p><a href="https://i.stack.imgur.com/XXiPJ.png" rel="nofollow noreferrer">Word Online crashing</a></p>