php - Regexp matching 3 consecutive capital letters -


i have following text :

74 avenue emile counor

bat b2 appt b104

i want replace line feed, if the following 3 letters not 3 capitals.

for example, previous example should become:

74 avenue emile counor bat b2 appt b104

but

74 avenue emile counor

bat b2 appt b104

should stay.

i have tried many solutions via regexp tools, impossible match want.

here have tried far

preg_replace("/\n([^a-z]{3})/", " $1", $str) 

if want negate following lf, way use negative lookahead:

$str = preg_replace("/\n(?![a-z]{3})/", " ", $str); 

note lookahead test , content doesn't appear in match result.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -