Note that there are some explanatory texts on larger screens.

plurals
  1. PORegEx match strings
    primarykey
    data
    text
    <p>I have a question related to regular expressions in c#.</p> <p>I want to find text between " characters. Example:</p> <pre><code> Enum resultado = SPDialogBox.Instance.show&lt;ACTION_ENUMs.TORNEO_SORTEAR&gt;("Esto es una prueba"); </code></pre> <p>Matches: <code>Esto es una prueba</code></p> <p>But, in this example</p> <pre><code>Enum resultado = SPDialogBox.Instance.show&lt;ACTION_ENUMs.TORNEO_SORTEAR&gt;("Esto es una prueba"); pKR_MESAPUESTOASIGNACION.CONFIGTORNEO_ID = Valid.GetInt(dr.Cells["CONFIGTORNEO_ID"].Value); </code></pre> <p>Matches: <code>Esto es una prueba</code> but must not match <code>CONFIGTORNEO_ID</code>, because it is written between square brackets (<code>[]</code>)</p> <p>In brief, I want to match string between double quote (<code>"</code>) characters, but that string must not be written between square brackets (<code>[]</code>).</p> <p>Here is my code:</p> <pre><code>var pattern = "\"(.*?)\""; var matches = Regex.Matches(fullCode, pattern, RegexOptions.Multiline); foreach (Match m in matches) { Console.WriteLine(m.Groups[1]); } </code></pre> <p>That pattern matches all string between <code>"</code> characters, but how can I modify the pattern to exclude those string that are written between square brackets?</p> <p>-- edit ---</p> <p>here is another example:</p> <pre><code>List&lt;String&gt; IdSorteados = new List&lt;String&gt;(); int TablesToSort = 0; foreach (UltraGridRow dr in fg.hfg_Rows) { if (dr.Cells["MESA_ID"].Value == DBNull.Value &amp;&amp; dr.Cells["Puesto"].Value == DBNull.Value &amp;&amp; !Valid.GetBoolean(dr.Cells["BELIMINADO"].Value) &amp;&amp; (Valid.GetBoolean(dr.Cells["Seleccionado"].Value) || SortearTodo)) TablesToSort++; } </code></pre> <p>The expression must not match <code>MESA_ID</code> ( found within <code>Cells["MESA_ID"].Value</code> ) nor <code>Puesto</code> (found within <code>Cells["Puesto"].Value</code> ). It also must not match <code>].Value == DBNull.Value &amp;&amp; dr.Cells[</code> (found within <code>["MESA_ID"].Value == DBNull.Value &amp;&amp; dr.Cells["Puesto"]</code> )</p> <p>I hope I have made my intent clear.</p>
    singulars
    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.
 

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