Hi.
I need to delete the whole sentence which contains two consecutive words beginning with large letters, as in the example below
"My name is Michael Holbrook"
"Student at the University Manchester, I have attended several"

Thanks to who helps me

    Might need a little more context here. Are there multiple sentences in the text, from which you may want to remove certain sentences; or are you talking about parsing one "sentence" at a time, however that it being determined? If the former, the first problem is determining what is a sentence -- which can get tricky when dealing with abbreviations (like "etc."), various punctuation marks, etc....

      Idea is this.
      $var="Student at the University Manchester, I have attended several";
      IF $var (contains two consecutive words beginning with Uppercase letters) , echo $var="ok";

        Okay, so how should "Student at Yale, I have attended several" be treated? Does "Yale, I" count as 2 consecutive capitalized words? (I'm guessing not?).

        A starting point might be something like:

        $regex = '/[A-Z]\S+\s+[A-Z]\S+/';
        preg_match_all($regex, $var, $matches);
        if(count($matches[0]) {
          // one or more such sequences found
        }
        

        Things will start to get more complicated if we start worrying about punctuation, quotes, etc.

        12 days later

        thanks, everything works, and what i was looking for

          Write a Reply...