Closed jonathanhunsucker closed 10 years ago
Searching for "cs1331" should return the same results as "cs 1331". This preg_replace adds the space if it matches the former format.
Test of the regex:
$queries = array( 'c', 'cs', 'cs1', 'cs123', 'cs 123', 'csasfsafas', 'math', 'loss', 'loss michael', ); $regex = '/^([A-Za-z]*)(\d*)$/'; $replacement = '$1 $2'; foreach ($queries as $query) { echo $query . ' -> ' . preg_replace($regex, $replacement, $query) . "\n"; }
Output:
$ php test-fuzzy-search.php c -> c cs -> cs cs1 -> cs 1 cs123 -> cs 123 cs 123 -> cs 123 csasfsafas -> csasfsafas math -> math loss -> loss loss michael -> loss michael
This looks reasonable; @cobookman?
I'll merge it. But the critique.gatech.edu webpage will not be updated, as I'm no longer in charge of that. I've setup issue #31.
Searching for "cs1331" should return the same results as "cs 1331". This preg_replace adds the space if it matches the former format.
Test of the regex:
Output: