Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This one will do a pretty good job. My definition of a sentence: A sentence begins with a non-whitespace and ends with a period, exclamation point or a question mark (or end of string). There may be a closing quote following the ending punctuation.</p> <p><code>[^.!?\s][^.!?]*(?:[.!?](?!['"]?\s|$)[^.!?]*)*[.!?]?['"]?(?=\s|$)</code> </p> <pre class="lang-java prettyprint-override"><code>import java.util.regex.*; public class TEST { public static void main(String[] args) { String subjectString = "This is a sentence. " + "So is \"this\"! And is \"this?\" " + "This is 'stackoverflow.com!' " + "Hello World"; String[] sentences = null; Pattern re = Pattern.compile( "# Match a sentence ending in punctuation or EOS.\n" + "[^.!?\\s] # First char is non-punct, non-ws\n" + "[^.!?]* # Greedily consume up to punctuation.\n" + "(?: # Group for unrolling the loop.\n" + " [.!?] # (special) inner punctuation ok if\n" + " (?!['\"]?\\s|$) # not followed by ws or EOS.\n" + " [^.!?]* # Greedily consume up to punctuation.\n" + ")* # Zero or more (special normal*)\n" + "[.!?]? # Optional ending punctuation.\n" + "['\"]? # Optional closing quote.\n" + "(?=\\s|$)", Pattern.MULTILINE | Pattern.COMMENTS); Matcher reMatcher = re.matcher(subjectString); while (reMatcher.find()) { System.out.println(reMatcher.group()); } } } </code></pre> <p>Here is the output:</p> <p><code>This is a sentence.</code><br> <code>So is "this"!</code><br> <code>And is "this?"</code><br> <code>This is 'stackoverflow.com!'</code><br> <code>Hello World</code> </p> <p>Matching all of these correctly (with the last sentence having no ending punctuation), turns out to be not so easy as it seems!</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