Jump to content

PHP regex to rip out all grammar


Dooley28

Recommended Posts

Oh...you want to put every word into an array?

 

<?php

  $str = "This is a sentence that I'm using to test";
  preg_match_all('/[aA-zZ\'\.]+/', $str,$words);

?>

 

Above returns....

 

Array
(
    [0] => Array
        (
            [0] => This
            [1] => is
            [2] => a
            [3] => sentence
            [4] => that
            [5] => I'm
            [6] => using
            [7] => to
            [8] => test
        )

)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.