Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Description</h1> <p>Based on your comments: <code>A word in this instance is:</code></p> <pre><code>a whole word without numbers doesn't start with a forward slash, or a back slash just letters only can include hyphen and apostrophes </code></pre> <p>The character class to cover all the word characters by your definition would be <code>[a-z'-]+</code> and that group could be surrounded by whitespace, or the start/end of a string. You sample also shows a comma so I'm presuming a word can be followed by a comma or dot either of which are followed by white space is ok too.</p> <p>This regex will:</p> <ul> <li>collect all substings defined as words <code>[a-z'-]+</code></li> <li>allow a comma or dot after a word, but not inside or at the start of a word</li> <li>rejects substrings from containing all hyphens</li> <li>rejects substrings from containing all apostrophes</li> <li>prevents words from having 3 or more hyphens</li> <li>prevents words from having 2 or more apostrophes</li> </ul> <p><code>(?:^|\s)(?![\\\/])(?!-+(?:\s|$))(?!'+(?:\s|$))(?!(?:[a-z'-]*?-){3,})(?!(?:[a-z'-]*?'){2,})[a-z'-]+[,.]?(?=\s|$)</code></p> <p><img src="https://i.stack.imgur.com/fg91R.png" alt="enter image description here"></p> <h1>Expanded explanation</h1> <ul> <li><code>(?:^|\s)</code> match the start of the string or a white space. This eliminates the need to test for word boundary which is problematic for strings like "abdc-egfh"</li> <li><code>(?![\\\/])</code> prevent the word from starting with a \ or /, however this is over kill as the character class doesn't allow it either</li> <li><code>(?!-+(?:\s|$))</code> prevent strings which are all hyphens</li> <li><code>(?!'+(?:\s|$))</code> prevent strings which are all apostrophes</li> <li><code>(?!(?:[a-z'-]*?-){3,})</code> prevent strings which have 3 or more hyphens</li> <li><code>(?!(?:[a-z'-]*?'){2,})</code> prevent strings which have 2 or more apostrophes</li> <li><code>[a-z'-]+[,.]?(?=\s|$)</code> match the word followed by some optional punctuation, and ensure this is followed by either a space or the end of a string</li> </ul> <h1>Examples</h1> <p>I'm not a C# programmer, but a returned array of matches from a code block like the one covered in question <a href="https://stackoverflow.com/questions/7417206/return-a-array-list-using-regex">Return a array/list using regex</a> and this regular expression will probably work for you. Note this expression does assume you'll use the case insensitive option.</p> <p><strong>Sample Text</strong></p> <pre><code>\DR1234 - this is a word, 123456, frank's place DA123 SW1 :50:/ one-hyphen two-hyphens-here I-have-three-hyphens </code></pre> <p><strong>Matches</strong></p> <pre><code>[0] =&gt; this [1] =&gt; is [2] =&gt; a [3] =&gt; word, [4] =&gt; frank's [5] =&gt; place [6] =&gt; one-hyphen [7] =&gt; two-hyphens-here </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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