Your first capture group matches a string of no more than 23 characters that is followed by a word break optionally followed by a punctuation mark that is followed by a word break
You expect this to match “They get rid of things” (22 characters) Which is followed by a word break (between the letter “s” and the non-letter “,”) And the following punctuation mark (comma) Which is followed be a word break — and there is the error. Neither the comma nor the following space is a letter, so the comma is not followed by a word break. Instead, it matches “They get rid of things” (22 characters) Which is followed by a word break (between the letter “s” and the non-letter “,”) Not the comma, which is OK, because the punctuation mark is optional Followed by a word break — still the same word break between “s” and “,”. So the first capture group matches up to, but not including, the comma. Regards, Neil Faiman > On Apr 8, 2025, at 5:09 AM, Otto Munters <[email protected]> wrote: > > Error in regex for BBedit: > What is wrong in this regex? > (?=^.{42,}$)(.{,23}\b[,.:;"!?]?\b)(.*) > > problem: the comma is also moved with capture group 2, it should stay with > capture group 1 > > Example, whole sentence to be split in two parts: > They get rid of things, very simple clothing. > > regex with error returns: > 1st line: They get rid of things > 2nd line: , very simple clothing. > > should be: > 1st line: They get rid of things, > 2nd line: very simple clothing. > -- This is the BBEdit Talk public discussion group. If you have a feature request or believe that the application isn't working correctly, please email "[email protected]" rather than posting here. Follow @bbedit on Mastodon: <https://mastodon.social/@bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/bbedit/6F493C68-8530-4544-9EB7-6A3DA674A158%40faiman.org.
