Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex Query Help - Lookbehind
    primarykey
    data
    text
    <p>This is somewhat related to: <a href="https://stackoverflow.com/questions/15278728/regular-expression-formatting-text-in-a-block-im">Regular Expression - Formatting text in a block - IM</a> but a different problem.</p> <p>Looking for <code>-</code>'s wrapping text with the following conditions:</p> <p>Conditions:</p> <ul> <li>token can be at start or end of line</li> <li>token must be surround by space or one or more symbols: {.,!@#$....}. <ul> <li>must not be a normal character [a-zA-Z] surrounding the <code>-</code> pair in question.</li> <li>See Sample test 3 ...w-thank you-</li> <li>Test 4 and 5 succeed because the <code>-</code> is wrapped with [^a-zA-Z]</li> </ul></li> <li>token must not be followed by a space on the first <code>-</code> or a space preceding the last <code>-</code> <ul> <li>"-Wow -" will not be a match as the closing <code>-</code> was preceded by a space.</li> <li>See Sample test 6 and 7</li> </ul></li> </ul> <p>For the front of the regular expression I would need: <code>(^|[\s\W]+)</code><br /> and the end would be: <code>($|[\s\W]+)</code></p> <p>I have the current expression, but it is failing due to the escape condition being stop after finding the first <code>-</code></p> <pre><code> (^|[\s\W]+)-([^\s][^-]*)-($|[\s\W]+) </code></pre> <p>Sample test strings would be:</p> <ol> <li>(all.): <code>-Wow-thank you-.</code></li> <li>(Wow): <code>-Wow- thank you-!</code></li> <li>(NIL): <code>- Wow-thank you-.</code></li> <li>(thank you): <code>- Wow!-thank you-</code></li> <li>(thank you): <code>- Wow -thank you-</code></li> <li>(all): <code>-Wow - thank you-</code></li> <li>(NIL): <code>-Wow - thank you -</code></li> </ol> <p>Does this require look behind? (I'm a regex newbie so please bear with me) Or is my middle condition totally wrong.</p> <p>Thank you much!<br /> mwolfe.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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