Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The brute force algorithm you're using performs in <em>O(nm)</em> time, where <em>n</em> is the length of the string being searched and <em>m</em> the length of the substring/pattern you're trying to find. You need to use a <strong>string search algorithm</strong>:</p> <ul> <li><p>Boyer-Moore is "the standard", I think: <a href="http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm" rel="noreferrer">http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm</a></p></li> <li><p>But there are lots more out there: <a href="http://www-igm.univ-mlv.fr/~lecroq/string/" rel="noreferrer">http://www-igm.univ-mlv.fr/~lecroq/string/</a></p></li> <li><p>including Morris-Pratt: <a href="http://www.stoimen.com/blog/2012/04/09/computer-algorithms-morris-pratt-string-searching/" rel="noreferrer">http://www.stoimen.com/blog/2012/04/09/computer-algorithms-morris-pratt-string-searching/</a></p></li> <li><p>and Knuth-Morris-Pratt: <a href="http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm" rel="noreferrer">http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm</a></p></li> </ul> <p>However, using a regular expression crafted with care <em>might</em> be sufficient, depending on what you are trying to find. See <a href="http://regex.info/blog/" rel="noreferrer">Jeffrey's Friedl</a>'s tome, <a href="http://regex.info/" rel="noreferrer"><em>Mastering Regular Expressions</em></a> for help on building efficient regular expressions (e.g., no backtracking).</p> <p>You might also want to consult a good algorithms text. I'm partial to Robert Sedgewick's <a href="http://algs4.cs.princeton.edu/home/" rel="noreferrer"><em>Algorithms</em></a> in its <a href="http://www.cs.princeton.edu/~rs/" rel="noreferrer">various incarnations</a> (<em>Algorithms in [C|C++|Java]</em>)</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