nCardot
nCardot

Reputation: 6587

Find lower case letter not followed by period

I need to find to find any instance of a comma followed by a line break then a lower case letter that is not immediately followed by a period. I tried (,)\r\n([a-z][^\.]), which didn't work. My goal is to replace the line breaks with a space using $1 $2 (assuming there would still be capturing groups).

Upvotes: 0

Views: 106

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626758

First of all, check if Match case option is on. It must be on, or your patterns will be case insensitive by default, unless you use (?-i) or (?-i:...).

Then, to match a linebreak, you may use \R and to assert the absence of a dot on the right, you may use a negative lookahead, (?!\.).

Hence, you may use

(?-i),\R([a-z])(?!\.)

and replace with ,$1.

Details

  • (?-i) - turn on case sensitivity
  • , - match a comma
  • \R - a line break sequence
  • ([a-z]) - Group 1: a lowercase ASCII letter
  • (?!\.) - no dot is allowed immediately to the right of the current location.

Upvotes: 1

Related Questions