The regular expression: (?-imsx:(?:(?<=\.|\!|\?)(?<!Mr\.|Dr\.)(?<!U\.S\.A\.)\s+(?=[A-Z]))) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- (?: group, but do not capture: ---------------------------------------------------------------------- (?<= look behind to see if there is: ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- \! '!' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- \? '?' ---------------------------------------------------------------------- ) end of look-behind ---------------------------------------------------------------------- (?<! look behind to see if there is not: ---------------------------------------------------------------------- Mr 'Mr' ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- Dr 'Dr' ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- ) end of look-behind ---------------------------------------------------------------------- (?<! look behind to see if there is not: ---------------------------------------------------------------------- U 'U' ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- S 'S' ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- A 'A' ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- ) end of look-behind ---------------------------------------------------------------------- \s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- (?= look ahead to see if there is: ---------------------------------------------------------------------- [A-Z] any character of: 'A' to 'Z' ---------------------------------------------------------------------- ) end of look-ahead ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
In reply to Re: Help Me Understand This Regex
by wwe
in thread Help Me Understand This Regex
by sanju87
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |