diff --git a/build/index.php b/build/index.php
index a0ec337..34427dc 100644
--- a/build/index.php
+++ b/build/index.php
@@ -1268,47 +1268,27 @@ register_module([
 			
 			$index = [];
 			
+			// Regex from 
+			$terms = preg_split("/((^\p{P}+)|(\p{P}*\s+\p{P}*)|(\p{P}+$))/", $source, -1, PREG_SPLIT_NO_EMPTY);
+			$i = 0;
+			foreach($terms as $term)
+			{
+				$nterm = strtolower($term);
+				if(!isset($index[$nterm]))
+				{
+					$index[$nterm] = [ "freq" => 0, "offsets" => [] ];
+				}
+				
+				$index[$nterm]["freq"]++;
+				$index[$nterm]["offsets"][] = $i;
+				
+				$i++;
+			}
+			
 			var_dump($env->page);
 			var_dump($source);
 			echo("source length: $source_length\n");
 			
-			$basepos = 0;
-			$scanpos = $basepos;
-			while($basepos < $source_length)
-			{
-				$word = "";
-				do {
-					// Break if we reach the end of the source text
-					if($scanpos >= $source_length) break;
-					$word .= $source[$scanpos];
-					$scanpos++;
-				} while(strpos($breakable_chars, $source[$scanpos]) === false);
-				
-				// Move the base position up to the scan position (plus one to
-				// skip over the breakable character), saving the old base
-				// position for later
-				$word_start_pos = $basepos;
-				$basepos = $scanpos + 1;
-				// Continue if the word is empty
-				if(strlen($word) === 0) continue;
-				// Normalise the word to be lowercase
-				$word = strtolower($word);
-				
-				var_dump($word);
-				
-				// Initialise the entry in the index if it doesn't exist
-				if(!isset($index[$word]))
-				{
-					$index[$word] = [
-						"freq" => 0,
-						"offsets" => []
-					];
-				}
-				// Update the index entry
-				$index[$word]["freq"]++;
-				$index[$word]["offsets"][] = $word_start_pos;
-			}
-			
 			var_dump($index);
 		});
 	}
diff --git a/module_index.json b/module_index.json
index 1862e6d..9f6441e 100644
--- a/module_index.json
+++ b/module_index.json
@@ -50,7 +50,7 @@
         "author": "Starbeamrainbowlabs",
         "description": "Adds proper search functionality to Pepperminty Wiki. Note that this module, at the moment, just contains test code while I figure out how best to write a search engine.",
         "id": "feature-search",
-        "lastupdate": 1445980152,
+        "lastupdate": 1446019292,
         "optional": false
     },
     {
diff --git a/modules/feature-search.php b/modules/feature-search.php
index 1e80fc9..64567fb 100644
--- a/modules/feature-search.php
+++ b/modules/feature-search.php
@@ -18,47 +18,27 @@ register_module([
 			
 			$index = [];
 			
+			// Regex from 
+			$terms = preg_split("/((^\p{P}+)|(\p{P}*\s+\p{P}*)|(\p{P}+$))/", $source, -1, PREG_SPLIT_NO_EMPTY);
+			$i = 0;
+			foreach($terms as $term)
+			{
+				$nterm = strtolower($term);
+				if(!isset($index[$nterm]))
+				{
+					$index[$nterm] = [ "freq" => 0, "offsets" => [] ];
+				}
+				
+				$index[$nterm]["freq"]++;
+				$index[$nterm]["offsets"][] = $i;
+				
+				$i++;
+			}
+			
 			var_dump($env->page);
 			var_dump($source);
 			echo("source length: $source_length\n");
 			
-			$basepos = 0;
-			$scanpos = $basepos;
-			while($basepos < $source_length)
-			{
-				$word = "";
-				do {
-					// Break if we reach the end of the source text
-					if($scanpos >= $source_length) break;
-					$word .= $source[$scanpos];
-					$scanpos++;
-				} while(strpos($breakable_chars, $source[$scanpos]) === false);
-				
-				// Move the base position up to the scan position (plus one to
-				// skip over the breakable character), saving the old base
-				// position for later
-				$word_start_pos = $basepos;
-				$basepos = $scanpos + 1;
-				// Continue if the word is empty
-				if(strlen($word) === 0) continue;
-				// Normalise the word to be lowercase
-				$word = strtolower($word);
-				
-				var_dump($word);
-				
-				// Initialise the entry in the index if it doesn't exist
-				if(!isset($index[$word]))
-				{
-					$index[$word] = [
-						"freq" => 0,
-						"offsets" => []
-					];
-				}
-				// Update the index entry
-				$index[$word]["freq"]++;
-				$index[$word]["offsets"][] = $word_start_pos;
-			}
-			
 			var_dump($index);
 		});
 	}
