Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Break down your regex to see why it doesn't work. </p> <pre><code>.*?(?&lt;columnname&gt;.+?)(?&lt;operator&gt;=|&lt;|&gt;|&lt;&gt;)(?&lt;value&gt;.+?)\s </code></pre> <ul> <li><code>.*?</code> &mdash; 0 or more characters, non-greedy.</li> <li><code>(?&lt;columnname&gt;.+?)</code> &mdash; 1 or more characters, which can be anything, non-greedy, capture into <code>columnname</code>. </li> <li><code>(?&lt;operator&gt;=|&lt;|&gt;|&lt;&gt;)</code> &mdash; One of <code>=</code>, <code>&lt;</code>, <code>&gt;</code>, or <code>&lt;&gt;</code>, capture into <code>columnname</code></li> <li><code>(?&lt;value&gt;.+?)</code> &mdash; 1 or more characters, which can be anything, non-greedy, capture into <code>value</code></li> <li><code>\s</code> &mdash; Must match a whitespace character here</li> </ul> <p>The only restrictions here are what you expect to find in <code>operator</code> and the single whitespace at the end of the string. Are you feeding the entire query into the regex, or just the string you gave as an example?</p> <p>If you match this against the example string you gave </p> <pre><code>col1 = 5 and col1 &lt; 6 or col3 &lt;&gt; ? </code></pre> <p>you will find that you have a single space in <code>columnname</code>, then an equals sign in <code>operator</code>, then another single space and the number <code>5</code> in <code>value</code>. </p> <p>Making this work as you wish is problematic because you might have spaces in your identifiers. Something like this <em>might</em> work:</p> <pre><code>.*?(?&lt;columnname&gt;`.+?`|\S+)\s*(?&lt;operator&gt;=|&lt;|&gt;|&lt;&gt;)\s*(?&lt;value&gt;`.+?`|\S+) </code></pre> <p>The only changes I made here are that columnname and value must either be all non-whitespace, or they must be values surrounded by backticks. Also, there are optional spaces between the captures, and not a required one at the end.</p> <p>You might consider sharing your C# as well so that we can see how you are invoking the regex against the string, as given the regex will only match one column/operator/value set.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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