Can I use AltSearch to assign a paragraph style based on paragraph content? [closed]

asked 2018-11-24 21:45:05 +0200

artman gravatar image

updated 2018-11-24 22:09:52 +0200

I have imported a document from Google Docs which needs to be formatted slightly differently. The text uses two different paragraph styles. Each section of the text begins with one paragraph in style A (no-indent) and then follows with zero or more paragraphs in style B (indent).

My strategy is to format the entire document in style B to start with, since most of the text should be indented, and then go back and change the format to style A for the small percentage (but still hundreds) of paragraphs at the top of each section.

(I use "section" to refer generically to a chunk of text, not a Writer document section, although all the text I'm working with is in Writer sections.)

I think I can use AltSearch to find instances of style FOO and change them to style BAR. But what I need to do is to search on the content since each paragraph that I want to be in style A begins with a date (e.g. Wednesday, November 21, 2018), which can be identified with a regular expression, and then assign a style to that paragraph.

Is this possible? If so, how? If not, can you suggest an alternative strategy that will minimize typing and maximize accuracy? Thanks!

+++++++++

I'm going to post this anyway, even though it's a bit of an embarrassment since I should have figured this out myself. (Well, actually I did....) Possibly it will be helpful to others.

The solution is to select "Regular Expression" in AltSearch's options box. Then enter the Regular Expression of your choice in the Search Box. In the Replace box, use the following syntax: \P{text-indent}, where text-indent is the name of the style you want to apply. I assume the "P" indicates it's a paragraph style. Make sure you have the upper-case P, he added, not wanting to call attention to his error. ;-) I had the syntax wrong, which is why I couldn't get it to work.

On the plus side, AltSearch is a powerful tool.
On the minus side, the documentation could be a bit more idiot-proof.
On the plus side again, it's that much more satisfying when you get it to work for you.
Thank you, Tomas!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by ebot
close date 2018-11-25 09:48:38.266157

Comments

@artman has given himself the answer in his question.

ebot gravatar imageebot ( 2018-11-25 09:50:08 +0200 )edit