Jump to content

megatr0n

New Members
  • Posts

    3
  • Joined

  • Last visited

megatr0n's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks. It has a few hickups, but I can do the rest; it selects null characters.
  2. The regex that I have is not the best. It took me awhile to come up with that and it does find the matches I want. Using the preg_split() seems like the way to go.
  3. I am trying build a function that can uniformly change words.e. The black cat is sitting on the mat. I want every two words(or nth words) to end up like The MOD cat MOD sitting MOD the MOD. The words are changed uniformly. Currently I have: $alltext = 'The black cat is sitting on the mat'; //using regex break text into words into an array $pattern = '/([a-zA-Z]|\xC3[\x80-\x96\x98-\xB6\xB8-\xBF]|\xC5[\x92\x93\xA0\xA1\xB8\xBD\xBE]){1,}/'; $n_words = preg_match_all($pattern, $input_str, $match_arr, PREG_OFFSET_CAPTURE); $wordcnt = 0; foreach ($match_arr[0] as $val) { $wordcnt++; $aword = $val[0]; $wordpos = $val[1]; $alltext = str_ireplace($wordpos, $aword, 'MOD'.changer($aword),$alltext); } function changer($in) { $in = $in.'IFY'; return $in; } This does not replace nth words uniformly. How can do this?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.