Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>str.replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|") </code></pre> <p>Output:</p> <pre><code>[ 'This is a long string with some numbers [125.000,55 and 140.000] and an end.', 'This is another sentence.' ] </code></pre> <p>Breakdown:</p> <p><code>([.?!])</code> = Capture either <code>.</code> or <code>?</code> or <code>!</code></p> <p><code>\s*</code> = Capture 0 or more whitespace characters following the previous token <code>([.?!])</code>. This accounts for spaces following a punctuation mark which matches the English language grammar.</p> <p><code>(?=[A-Z])</code> = The previous tokens only match if the next character is within the range A-Z (capital A to capital Z). Most English language sentences start with a capital letter. None of the previous regexes take this into account.</p> <hr> <p>The replace operation uses:</p> <pre><code>"$1|" </code></pre> <p>We used one "capturing group" <code>([.?!])</code> and we capture one of those characters, and replace it with <code>$1</code> (the match) plus <code>|</code>. So if we captured <code>?</code> then the replacement would be <code>?|</code>.</p> <p>Finally, we split the pipes <code>|</code> and get our result.</p> <hr> <p>So, essentially, what we are saying is this:</p> <p>1) Find punctuation marks (one of <code>.</code> or <code>?</code> or <code>!</code>) and capture them</p> <p>2) Punctuation marks can optionally include spaces after them.</p> <p>3) After a punctuation mark, I expect a capital letter.</p> <p>Unlike the previous regular expressions provided, this would properly match the English language grammar.</p> <p>From there:</p> <p>4) We replace the captured punctuation marks by appending a pipe <code>|</code></p> <p>5) We split the pipes to create an array of sentences.</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.
    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