<?xml version="1.0" encoding="windows-1252"?>
<node id="111770" title="Re: Re: Re: Pattern Finding" created="2001-09-11 16:14:14" updated="2005-07-19 14:08:39">
<type id="11">
note</type>
<author id="31503">
runrig</author>
<data>
<field name="doctext">
&lt;em&gt;I would expect any of the following: 

hello,hi,othello,brake,rake,raker,rash,ash,hash,ohio,
the,lob,bra,hell,era&lt;/em&gt;
&lt;p&gt;I don't see how you could expect some of those strings, because some only appear once in the string (e.g. "othello", "ohio"), so you really couldn't call them a "pattern" unless you're matching against a dictionary file.
&lt;p&gt;My solution near the top of this thread sort of assumes that the string is a contiguous series of patterns (one of the original constraints was "String contains nothing but patterns"), so it only finds "hello" from your test string, but if you change this line:&lt;code&gt;
# From this
if (/\G(.{2,})(?=.*?\1)/g) {

# To this
if (/\G.*?(.{2,})(?=.*?\1)/g) {
&lt;/code&gt;
Then it does better and finds "ash", "rake", and "hello" from your test string, which is about as good as it gets, I believe.</field>
<field name="root_node">
111621</field>
<field name="parent_node">
111735</field>
</data>
</node>
