There is a file, in it sentences - one per line. But at the same time there are glued sentences (in the second line - a sentence starting with “The first”).

Make up family photos.
You will use. She gets ready to hit it back.

I need to find sentences in which, after a small letter, a big one immediately goes on, and then a small one (i.e., the second line in the example). And then decompose the normal sentences and glued together in different files.

$lines = file('text.txt'); foreach($lines as $line){ if (preg_match("#^(регулярка)$#i", $line)) file_put_contents('ok.txt', $line, FILE_APPEND | LOCK_EX); else file_put_contents('err.txt', $line, FILE_APPEND | LOCK_EX); } 

Help with the regular season.

  • And what is the "Offer", one would assume that the sentences are separated by dots, but this is not so, there may be abbreviations in which the dots are in the middle. In addition, the condition is small-big-small the same is not correct. No one bothers to start a single capital letter, for example, 'I', and if it is glued, it will be small-big-space. And the usual sentence may end in abbreviation in capital letters ... - Mike
  • The sentences in the file are separated by the line break \ n - sashaeee
  • Well, that is you stupid line where there is a small-big-small. Do not you guess. 3 minutes of reading an article on a regular wiki is enough to write /[az][AZ][az]/ , even if they were seen for the first time in their lives - Mike
  • My name is Rein I am lamer Is there not one-letter words? - ReinRaus

1 answer 1

after a small letter, immediately goes big, and then immediately small

if the letters are limited to the Latin alphabet, then a regular expression is enough:

 [az][AZ][az] 

if there is no such restriction (i.e., letters from other alphabets may occur), then it is better to use character classes :

 [:lower:][:upper:][:lower:]