Skip to main content
Legend
August 30, 2016
Answered

wildcards and empty lines

  • August 30, 2016
  • 4 replies
  • 2903 views

After importing a .docx file – well, sometimes we have to do these things – I was hoping to find empty lines with the (relatively) familiar ^$ wildcard, but all this is managing to locate is empty table-cells. Any hints?

This topic has been closed for replies.
Correct answer Barb Binder

Oops. My mistake. I wrote:

Find: \p| where I meant \P|

Replace: [blank]

Wildcards enabled

The case makes all the difference. It's in the screen shot correctly, but I typed it incorrectly.

When you have time, could you try it one more time, FieryPantone? I'm testing on 2015 and don't have 12 installed at this point.

4 replies

Barb Binder
Community Expert
Community Expert
November 17, 2016

FieryPantone​: I've been mulling over this question since you asked it back in August, and Lynne A. Price​'s valid concerns about my answer. Here's where I ended up:

To remove trailing spaces:

  • Turn on Regular Expressions
  • Find: \s+$
  • Change: [leave empty]

It's working great on my docs, but I'd love to hear if either of you discover any issues that I'm not experiencing.

And while I'm sharing queries, here's another one that I'm loving for removing those extra spaces that typists randomly add in the middle of their Word docs (2, 3, 10, whatever!)

  • Turn on Regular Expressions
  • Find: \h\h+
  • Change: [press the spacebar once]

Now if only we could save them in the Find/Change panel so that we don't have to keep typing them each day!

~Barb at Rocky Mountain Training
Legend
November 18, 2016

Thanks for the extra input! I'll keep you posted – though when I'm reusing content from a Word doc it's usually as part of a complete make-over involving a text editor with a query stack ;-}

Legend
August 31, 2016

Lots of interesting information, for which my thanks … but:

  • \p| selects both the paragraph markers, so [blank] as replace string joins the content either side of the empty paragraph and \p as replace string discards the style of the second [irritating but familiar behaviour]
  • ^$ only identifies empty cells in tables
  • \P\p finds absolutely nothing, despite what the Help says

Remedy? export to html, convert html tagging to mml, use editor to discard empty paragraphs … Remaining minor pain, reimport the tables by hand.

Barb Binder
Community Expert
Barb BinderCommunity ExpertCorrect answer
Community Expert
August 31, 2016

Oops. My mistake. I wrote:

Find: \p| where I meant \P|

Replace: [blank]

Wildcards enabled

The case makes all the difference. It's in the screen shot correctly, but I typed it incorrectly.

When you have time, could you try it one more time, FieryPantone? I'm testing on 2015 and don't have 12 installed at this point.

~Barb at Rocky Mountain Training
Legend
September 1, 2016

AHa! \P| does the trick … (curiously enough, so does \P\p, this morning; the wind must have changed) Thanks for the correction.

I'll bookmark this thread for future reference, though I did quite enjoy the .mml route ;-}

Inspiring
August 30, 2016

Dear Fiery,

   Try ^\n. If it doesn't work, check maker.ini and make sure the regular expression syntax option is set to Perl.

     --Lynne

Barb Binder
Community Expert
Community Expert
August 30, 2016

I use:

Find: \p|

Change: [blank]

wildcards on

I think you said previously you are on Fm12? 2015 can now remove the returns on import, fyi.

~Barb at Rocky Mountain Training
Inspiring
August 30, 2016

Barb,

   Remember that the | wildcard matches spaces or punctuation. Hence \p| or \P| find paragraphs containing only spaces and punctuation as well as those that are empty or contain only spaces.

   By the way, in a simple search, I was surprised to discover that \P\p finds paragraphs only markers or anchors. Furthermore, Change All of \P\p deletes paragraphs containing only anchors (but not those containing only markers). The anchored table or anchored frame is not deleted; the anchor moves to the next paragraph. I detected this behavior in FM 2015 and confirmed it in FM 9 but did not test in intervening or earlier versions.

     --Lynne

Barb Binder
Community Expert
Community Expert
August 30, 2016

Hi Lynne!

I use that combo for this situation, which I thought FieryPantone was asking about, but perhaps I misunderstood?

Of course with GREP we have better options now!

~Barb at Rocky Mountain Training