[Solved] Find and Replace with Regex Not Working

Discuss the word processor
Post Reply
User avatar
ChasVA
Posts: 16
Joined: Tue May 31, 2016 11:14 am

[Solved] Find and Replace with Regex Not Working

Post by ChasVA »

Hello,

I'm trying to convert bold- and italic-formatted text to use HTML tags and am having no luck. It's a bit tricky, as some sentences have a mix of Bold and Italic, like this:

The quick brown fox jumped over the lazy dog.

With Regular Expressions checked, In the Search for box, I've entered

Code: Select all

(.*)
and chosen More Options>Format>11pt>bold,italic (the font size avoids any headers that I don't want to change). I also tried

Code: Select all

(.+)
In the Replace with box I've entered

Code: Select all

<b>$1</b>
and chosen 11pt, italic, normal. (The plan was to put in all the bold tags and then do the italics tags.)

The problem is that Writer returns "Search key not found". If I click on "No Format", it just finds the first paragraph, so the RegEx doesn't seem to work with formatting. Is this the case?
Last edited by ChasVA on Mon Jun 11, 2018 2:20 am, edited 1 time in total.
Version: OpenOffice 4.1.5
OS: Win 8.1 64-bit

Never try to second-guess the clueless. Malcolm Gordon
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Find and Replace with Regex Not Working

Post by RoryOF »

I have just tried, using Find .* and Replace <b>&</b> and it worked correctly.

Note: no brackets about the Find parameters, and & used in place of $1
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Find and Replace with Regex Not Working

Post by John_Ha »

See [Tutorial] How to record a macro (and Regular Expressions).

As a new poster you will find much useful information in the Writer FAQ, the Writer Tutorials, the up to date Writer guide and the Writer Manual. May I suggest you bookmark the pages.

Press F1 to access the Help screen and search for your problem

The chapter headings in the manual are:

1 - Introducing Writer
2 - Setting up Writer
3 - Working with Text
4 - Formatting Pages
5 - Printing, Exporting, Faxing and E-Mailing
6 - Introduction to Styles
7 - Working with Styles
8 - Working with Graphics
9 - Working with Tables
10 - Working with Templates
11 - Using Mail Merge
12 - Tables of Contents, Indexes and Bibliographies
13 - Working with Master Documents
14 - Working with Fields
15 - Using Forms in Writer
16 - Customizing Writer – Keyboard shortcuts.

When a pop-up window opens, click the Help button for extensive help on that function - it is often more comprehensive than the manual.
Last edited by John_Ha on Mon May 21, 2018 12:35 pm, edited 1 time in total.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Bill
Volunteer
Posts: 8934
Joined: Sat Nov 24, 2007 6:48 am

Re: Find and Replace with Regex Not Working

Post by Bill »

ChasVA wrote:With Regular Expressions checked, In the Search for box, I've entered

Code: Select all

(.*)
and chosen More Options>Format>11pt>bold,italic (the font size avoids any headers that I don't want to change).
Format > 11pt, bold, Italic will only find 11pt text with both bold and Italic. If you want to find 11pt text with bold only, you need to choose Format > 11pt, bold.
AOO 4.1.14 on Ubuntu MATE 22.04
User avatar
ChasVA
Posts: 16
Joined: Tue May 31, 2016 11:14 am

Re: Find and Replace with Regex Not Working

Post by ChasVA »

I solved my original question (it just started working where it hadn't before—not the first time that's happened in OO).
Version: OpenOffice 4.1.5
OS: Win 8.1 64-bit

Never try to second-guess the clueless. Malcolm Gordon
Post Reply