in reply to Help Me Understand This Regex
my $string = "Hello Mr. Jack! How are you? Everything is OK. That's fi +ne!"; my @sentances = split(/ (?<=\.|\!|\?) # true if in the left side is any of [.!?] # - end of a sentence (?<!Mr\.|Dr\.) # true if in the left side is *NOT* any of ("Mr." | "D +r.") (?<!U\.S\.A\.) # true if in the left side is *NOT* "U.S.A." # - ends with a dot, but is the end of a sentence \s+ # true if in the current possition is space # - space between words (?=[A-Z]) # true if in the right side is a capital A-Z # - start of a new sentence /x, $string); print $_,"\n" for @sentances;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help Me Understand This Regex
by sanju87 (Initiate) on Apr 07, 2012 at 08:13 UTC |