title: How to design a regex used for searching a pattern, rather than validating a pattern?
body: <p>As we learned, given a regex pattern (e.g., <code>A B A B A C</code>), we can convert it to a DFA. In this example, it would be like a chain (you can test it <a href="http://hackingoff.com/compilers/regular-expression-to-nfa-dfa" rel="nofollow">here</a>). </p>
  
  <p>This "chain-like" DFA can tell if a given string match the pattern or not (i.e., accept/reject it); But it <strong>cannot tell if there is any occurrence within the string and identify all of them</strong>.</p>
  
  <p><strong>Example:</strong>
  Suppose this is the to-search string: <code>A B C A B A B A B A C A B C</code></p>
  
  <p>Although there is an occurrence starting from the 6th character, the "chain-like" DFA cannot tell this. All it can do is to <strong>reject</strong> this string.</p>
  
  <p><strong>Question</strong>: Is it possible to design a regex that support such functionality?</p>
  
  <p>(Note: I understand this question is kind of confusing; I would like to clarify it confuses you.)</p>