Changeset 434
- Timestamp:
- Nov 8, 2013 3:56:09 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1dev/lib/SpellCheck.inc.php
r431 r434 186 186 187 187 /** 188 * Returns an array of suggested words for each mis pelled word in the given text.188 * Returns an array of suggested words for each misspelled word in the given text. 189 189 * The first word of the returned array is the (possibly) misspelled word. 190 190 * … … 201 201 // Split words on punctuation except apostrophes (this regex is used in several places in this class). 202 202 // http://stackoverflow.com/questions/790596/split-a-text-into-single-words 203 $words = preg_split("/(( ^\p{P}+)|(\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(\p{P}+$))/", $string);203 $words = preg_split("/((?:^\p{P}+)|(?:\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(?:\p{P}+$))/", $string, -1, PREG_SPLIT_DELIM_CAPTURE); 204 204 if (is_array($words) && !empty($words)) { 205 205 // Remove non-word elements. … … 237 237 // Split words on punctuation except apostrophes (this regex is used in several places in this class). 238 238 // http://stackoverflow.com/questions/790596/split-a-text-into-single-words 239 $words = preg_split("/(( ^\p{P}+)|(\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(\p{P}+$))/", $string);239 $words = preg_split("/((?:^\p{P}+)|(?:\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(?:\p{P}+$))/", $string, -1, PREG_SPLIT_DELIM_CAPTURE); 240 240 if (is_array($words) && !empty($words)) { 241 241 // Remove non-word elements. … … 270 270 // Split words on punctuation except apostrophes (this regex is used in several places in this class). 271 271 // http://stackoverflow.com/questions/790596/split-a-text-into-single-words 272 $words = preg_split("/(( ^\p{P}+)|(\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(\p{P}+$))/", $string);272 $words = preg_split("/((?:^\p{P}+)|(?:\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(?:\p{P}+$))/", $string, -1, PREG_SPLIT_DELIM_CAPTURE); 273 273 $cnt = 0; 274 274 if (is_array($words) && !empty($words)) { … … 279 279 $footnote = $show_footnote ? '<sup style="color:#999;">' . ++$cnt . '</sup>' : ''; 280 280 $words[$i] = $this->getParam('highlight_start') . $word . $this->getParam('highlight_end') . $footnote; 281 } 282 } 283 } 284 return join(' ', $words); 285 } 286 287 /** 288 * Prints the HTML for correcting all mispellings found in the text of one $_FORM element. 281 $string = preg_replace("/\b$word\b/", $words[$i], $string); 282 } 283 } 284 } 285 return $string; 286 // return join(' ', $words); 287 } 288 289 /** 290 * Prints the HTML for correcting all misspellings found in the text of one $_FORM element. 289 291 * 290 292 * @access public … … 361 363 // Split words on punctuation except apostrophes (this regex is used in several places in this class). 362 364 // http://stackoverflow.com/questions/790596/split-a-text-into-single-words 363 $form_words = preg_split("/(( ^\p{P}+)|(\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(\p{P}+$))/", getFormData($form_name));365 $form_words = preg_split("/((?:^\p{P}+)|(?:\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(?:\p{P}+$))/", getFormData($form_name), -1, PREG_SPLIT_DELIM_CAPTURE); 364 366 $suggestions = getFormData('spelling_suggestions'); 365 367 $corrections = getFormData('spelling_corrections'); … … 379 381 380 382 if (is_array($form_words) && !empty($form_words)) { 381 return join(' 383 return join('', $form_words); 382 384 } else { 383 385 return getFormData($form_name);
Note: See TracChangeset
for help on using the changeset viewer.