Reply to topic  [ 4 posts ] 
Search for a string that is not within quotes. 
Author Message

Joined: 2008-10-14 12:50:18
Posts: 10
I'm looking for a way to search for a string of letters that is NOT contained within quotes. Anyone know how to make this happen using powersearch?

Specifically, I want to find words in my document that end in "ing" but that are not part of dialog.

For example, in the following section:

"Where are you going?" I asked.
He pointed to the waterfall flowing over the rocks. "On the other side of that," he said.


I would want NISUS to find flowing but to ignore going.


2009-06-12 08:22:41
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
I think this is going to be quite difficult (or impossible) to do using PowerFind alone. You could however use a Nisus Writer Pro macro.. this should do it:
Code:
$doc = Document.active
$matched = Array.new

# move to start of document
Select All
Select Start

# Find all words ending in "ing"
While Find Next '\w+ing', 'E-W'
   $selection = $doc.textSelection
   $isQuoted = false
   
   # only include if next quotation mark is an open quote
   If Find Next '(\s?)(["”“])', 'E-W$'
      If $2 == '”'
         $isQuoted = true
      ElseIf $2 == '"'
         $isQuoted = 0 == $1.length
      End
   End
   
   If ! $isQuoted
      $matched.appendValue($selection)
   End
   
   # restore ealier search location
   $doc.setSelection($selection)
End

If 0 == $matched.count
   Prompt "No 'ing' words found outside quoted text."
Else
   $doc.setSelections($matched)
End


2009-06-12 12:23:19
Profile WWW

Joined: 2008-10-14 12:50:18
Posts: 10
Hmmm. I don't have Pro, so I guess I can't implement this. But thanks for the effort. I appreciate it.


2009-06-12 13:24:54
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
Hopefully this would solve the problem.

1. Create a new Character Style Not Within Quotes or something alike having a visible attribute, e.g. highlight colour.

2. Find All \w+ing\b (word ending with ing) in PowerFind Pro mode.

3. Apply Not Within Quotes style on all occurrences found.

4. Find All ".+?" (text enclosed by straight quote) or “.+?” (text enclosed by curly quotes) to find/select all text portion within quotes.

5. Set Where to In Selection and Find All \w+ing\b to find/select all \w+ing\b within quotes.

6. Format:Character Style:Remove Style to remove Not Within Quotes style from all occurrences found.

Now only words ending with "ing" not within dialog have Not Within Quotes style.

To remove Not Within Quotes style entirely from the document, just delete the style in the Style Sheet.

If you often do this kind of operations, I think you'd better upgraded to Nisus Writer Pro in which you could use Invert Selection macro.


2009-06-12 17:59:32
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software