Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Let me focus on one line of your post. This is where the problem might be:</p> <blockquote> <p>The regex match is coming over HTTP wrapped in the body of a POST request.</p> </blockquote> <p>This seems problematic because:</p> <p>The only structures that survive serialization between client/server are:</p> <ul> <li><code>boolean</code></li> <li><code>number</code></li> <li><code>string</code></li> <li><code>null</code> *</li> <li><code>object</code>s and <code>array</code>s containing these basic types</li> <li><code>object</code>s and <code>array</code>s containing <code>object</code> and <code>arrays</code> [of more obj/array] of these basic types</li> </ul> <p><code>Regexp</code>, <code>Date</code>, <code>Function</code>, and a host of others require reconstruction, which means passing a string or pair of <code>string</code>s for the <code>match</code> and <code>option</code> components of the <code>Regexp</code> and running <code>Regexp()</code> on the receiving end to reconstruct.</p> <p><code>Regexp</code> gets a bit messy because <code>Regexp.toString()</code> and <code>Regexp()</code> do not appear to be inverses of each others: <code>/someMatch/.toString() is "/someMatch/"</code> but <code>RegExp("/someMatch/") is //someMatch//</code> and what was needed instead to rebuild the regexp was just <code>RegExp("someMatch")</code>, which is <code>/someMatch/</code>. I hope this helps.</p> <p><code>JSON.stringify(/someMatch/) is {}</code> (at least on Chrome). </p> <p>So instead of trying to build a general transport, I recommend re instantiating a particular field as a regexp.</p> <p>* Irrelevant note: (null is fine but undefined is peculiar. JSON won't stringify <code>undefined</code>s in objects and turns undefined into null in Arrays. I recognize this isn't part of your problem, just trying to be complete in describing what can be serialized.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload