I would like to use a Regex search to find the following: can anyone help me?

User avatar
vic-k
Posts: 7134
Joined: Fri Apr 27, 2007 8:23 am
Platform: Mac + Windows
Location: Protesting in the nude, outside ex Red Lion TESCO Store

Fri Dec 16, 2016 10:58 pm Post

Forwarded this from Scriv's lower deck ... can anybody help Sarah? :?

Sarah1986
Posts: 30
Joined: Tue Mar 05, 2013 4:34 am
Platform: Mac
Regex Search Terms
by Sarah1986 » Fri Dec 16, 2016 5:28 am

I would like to use a Regex search to find the following: can anyone help me?

Sentences that are longer than 25 words
Paragraphs that are longer than 4 sentences
Scrivener for Thesis & Dissertation Writing - posts, hints and best practice
http://www.thequalitativeresearcher.net

Coming Soon- Scrivener for Data Analysis and Scrivener for Literature Reviews
As a professional, you, are your one and only asset. Without integrity you are worthless, but with it, you are priceless.

da
dafu
Posts: 564
Joined: Tue Jan 30, 2007 1:33 am
Platform: Mac
Location: Chicago
Contact:

Sat Dec 17, 2016 3:50 am Post

Sarah,

You’re asking for a rather complicated pair of regex’s. :-)

You may say a “sentence” and have in mind a bunch of words terminated with a period but then how does this fit in?
“I saw Mr. Big the other day.”

So, unless you want to some mildly demented person to *really* figure out how to do these, take the sloppy road.

These seem to mostly work when run against the first chapter of Wuthering Heights.

Sentences longer than 25 words:

Code: Select all

([\w'’]+[^.!?\w]{1,3}){25,}[\w'’]+[.!?]

This roughly means: find at least 24 words that may have apostrophes in them that are followed by one to three characters that aren't word characters nor are they sentence terminations, followed by one word that is followed by a period or an exclamation mark or a question mark. Modify as you like but be *very* careful—complex regexs like this can blow-up easily.

Paragraphs longer than 4 sentences:

Code: Select all

^([^.\n]+?[.?!]){5,}


Find paragraphs with at least 5 spans of characters with a period, question mark or exclamation point marking them.

Happy hair-pulling.

Best
Dave

User avatar
Sarah1986
Posts: 46
Joined: Tue Mar 05, 2013 4:34 am
Platform: Mac

Tue Dec 20, 2016 3:11 am Post

Hi Dave,
Thanks - I'm using them for academic writing. I'll have a play and let you know how I go.

Thanks
Scrivener for Thesis & Dissertation Writing - posts, hints and best practice
www.thequalitativeresearcher.net

Coming Soon- Scrivener for Data Analysis and Scrivener for Literature Reviews