Replace is destroying line endings

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

geoffreykidd
Posts: 35
Joined: Thu Aug 02, 2007 8:50 pm

Post by geoffreykidd »

Thank you.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Please try this instead:
(?!^([^“�\r\n]++|“[^“�\r\n]*�)*$)^.+
which puts less of a strain on the recogniser.
geoffreykidd
Posts: 35
Joined: Thu Aug 02, 2007 8:50 pm

Post by geoffreykidd »

The revised RegEx worked beautifully. If I could possibly thank you enough, I would.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You're welcome. We're co-operating to give this new version a really good work-out. :-)
geoffreykidd
Posts: 35
Joined: Thu Aug 02, 2007 8:50 pm

Post by geoffreykidd »

One interesting note about the new RegEx. It works beautifully in 7.0.0,
but when I put it into RegEx Buddy with the PERL setting, I got back out a message: Perl does not support possessive quantifiers «+»

For the second "+" in the "++" sequence. It still worked in TextPad 7, though.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Possessive quantifiers were introduced into Perl in version 5.10, released in 2007.

What does RegEx Buddy have to say about this version:
(?!^(?>[^“�\r\n]+|“[^“�\r\n]*�)*$)^.+
which uses an "independent subexpression", which is what lies behind a possessive quantifier and stops backtracking?
geoffreykidd
Posts: 35
Joined: Thu Aug 02, 2007 8:50 pm

Post by geoffreykidd »

It passed RegEx Buddy in Perl mode with flying colors. I also just tried it on the earlier file that caused problems and a new text I just received. It worked beautifully in both cases.

Thank you.
geoffreykidd
Posts: 35
Joined: Thu Aug 02, 2007 8:50 pm

Post by geoffreykidd »

I checked the latest RegEx out in 7.0.4. No problems.
geoffreykidd
Posts: 35
Joined: Thu Aug 02, 2007 8:50 pm

Straight Quotes RegEx?

Post by geoffreykidd »

I've discovered I need to do the same gig as for curly quotes with straight quotes. Any suggestions? BTW, the curly quote regex is backed up on my systems. I occasionally look at it and mutter "My precious." :)
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Do you mean you want to find all lines that contain an odd number of straight quotes?

The obvious alteration to my previous suggestion will do that:
(?!^([^"\r\n]++|"[^"\r\n]*")*$)^.+

As will:
(?!^[^"\r\n]+(?:"[^"\r\n]*"[^"\r\n]*)*$)^.+
geoffreykidd
Posts: 35
Joined: Thu Aug 02, 2007 8:50 pm

Post by geoffreykidd »

The alteration wasn't obvious to me, I'm afraid. I can do a few things with regular expressions, RegEx 101 level. This stuff seems to be a lot higher level.

A thousand thanks.
Post Reply