[Solved] Regular Expression for empy cells
[Solved] Regular Expression for empy cells
I have the same problem. Openoffice implements ^ and $ characters incorrectly for regex. How we could add a word at the beggining of each cell? For example in the text editor Notepad++ we activate regex and replace ^ (beginning of line) for the word we want to add at the begining of the line.
I'm using OpenOffice 4. It's just a bug in the regex implementation. Please fix it.
Topic split and moved to the Calc forum. (Hagar, Moderator).
I'm using OpenOffice 4. It's just a bug in the regex implementation. Please fix it.
Topic split and moved to the Calc forum. (Hagar, Moderator).
Last edited by Hagar Delest on Sat Jul 02, 2016 3:30 pm, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
OpenOffice 4 / Windows 10
Re: Regular Expression beginning of paragraph (^) doesn't wo
AOO 3.1.0 (for Windows) is completely obsolete - we are now on 4.1.2. Are you on the latest release for LInux?
The Alternative Search add-on may work better because some of the add-on is implemented directly in code rather than in the macro language.
See Documentation > How Tos > Regular Expressions in Writer. Jeffrey Friedl's book Mastering Regular Expressions is excellent.
See [Tutorial] Differences between Writer and MS Word files for useful information.
If this solves the problem, please click the Edit button on your original post and add [Solved] in front of your subject.
The Alternative Search add-on may work better because some of the add-on is implemented directly in code rather than in the macro language.
See Documentation > How Tos > Regular Expressions in Writer. Jeffrey Friedl's book Mastering Regular Expressions is excellent.
See [Tutorial] Differences between Writer and MS Word files for useful information.
If this solves the problem, please click the Edit button on your original post and add [Solved] in front of your subject.
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.
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.
Re: Regular Expression beginning of paragraph (^) doesn't wo
To add a new word at the beginning of each cell in a table in writer or cells in Calc, I can search for
^.
and replace with
MyNewWord &
I assumed there is only one paragraph within the cells. That is the expected behavior. As acknak says above, the ^ does not by itself match the beginning of a paragraph, it means that the following expression must be at the beginning of a paragraph. You may be accustomed to different behavior but the detailed implementation of regular expressions does vary in different software.
^.
and replace with
MyNewWord &
I assumed there is only one paragraph within the cells. That is the expected behavior. As acknak says above, the ^ does not by itself match the beginning of a paragraph, it means that the following expression must be at the beginning of a paragraph. You may be accustomed to different behavior but the detailed implementation of regular expressions does vary in different software.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Regular Expression beginning of paragraph (^) doesn't wo
This is an ancient thread. The OP was using that version 7 years ago.John_Ha wrote:AOO 3.1.0 (for Windows) is completely obsolete - we are now on 4.1.2. Are you on the latest release for LInux?
AOO 4.1.14 on Ubuntu MATE 22.04
Re: Regular Expression beginning of paragraph (^) doesn't wo
Bill
Thanks. I wish people would start new threads!
Thanks. I wish people would start new threads!
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.
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.
Re: Regular Expression beginning of paragraph (^) doesn't wo
I found that ^$ doesn't work because finding empty cell is explicitly disabled in OpenOffice even if you are only searching a selection. You can read about that here in the section "Regular expressions in Calc Find & Replace":acknak wrote:It works for me. ^. finds the first character of every paragraph; ^$ finds empty paragraphs.
You can't use ^ all alone to find the beginning of paragraphs; it only "anchors" the rest of the pattern to match at the beginning of a paragraph.
What is the pattern you're searching for?
https://wiki.openoffice.org/wiki/Docume ... nd_replace
So it's sadly impossible to find or replace empty cells in OpenOffice with regular expressions.
That worked! and I found another possible solution too using regex groups:FJCC wrote:To add a new word at the beginning of each cell in a table in writer or cells in Calc, I can search for
^.
and replace with
MyNewWord &
I assumed there is only one paragraph within the cells. That is the expected behavior. As acknak says above, the ^ does not by itself match the beginning of a paragraph, it means that the following expression must be at the beginning of a paragraph. You may be accustomed to different behavior but the detailed implementation of regular expressions does vary in different software.
Search for:
^(.)
and Replace with:
MyNewWord$1
Thank you, bye!
OpenOffice 4 / Windows 10
Re: Regular Expression beginning of paragraph (^) doesn't wo
Please note that OO Calc and OO Writer are different in this respect. This topic and my comment were directed at someone using OO Writer; the result will be different if you're working in Calc.augus1990 wrote:... So it's sadly impossible to find or replace empty cells in OpenOffice with regular expressions. ...
Empty cells in a spreadsheet are completely empty; there's nothing to search so they never match any regular expression.
AOO4/LO5 • Linux • Fedora 23
Re: Regular Expression beginning of paragraph (^) doesn't wo
The Calc forum is hereaugus1990 wrote:... So it's sadly impossible to find or replace empty cells inOpenOfficeCalc with regular expressions. ...
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.
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.
Re: Regular Expression beginning of paragraph (^) doesn't wo
Just an update as of Dec 2018:acknak wrote:Please note that OO Calc and OO Writer are different in this respect. This topic and my comment were directed at someone using OO Writer; the result will be different if you're working in Calc.augus1990 wrote:... So it's sadly impossible to find or replace empty cells in OpenOffice with regular expressions. ...
Empty cells in a spreadsheet are completely empty; there's nothing to search so they never match any regular expression.
When I assign the formula ="a" and search for ^a$ on cell values I get a match, but when I change forumula to ="" and search for ^$ I do not get a match. This as a result of not able to find empty cells (Tried AOO 4.1.4 and LO 6.0.5.2). Empty Cell search is possible in Excel by leaving the Find-input empty.
It's Microsoft marketing that tells you computers are qualified for non-technicians
W11 22H2 (build 22621), LO 7.4.2.3(x64)
W11 22H2 (build 22621), LO 7.4.2.3(x64)
Re: [Solved] Regular Expression for empy cells
... and a roughly sketched emergency-workaround by user code in Basic:
This will not touch cells with empty formula result.
Code: Select all
Sub fillEmptyPartOfCurrentSelectionWith(Optional pNewString As String)
If IsMissing(pNewString) Then pNewString = "<found empty>"
doc0 = ThisComponent
rgs = doc0.CurrentSelection
e = rgs.queryEmptyCells
For Each rgA In e.RangeAddresses
With rgA
rg = doc0.Sheets(.Sheet).getCellRangeByPosition _
(.StartColumn, .StartRow, .EndColumn, .EndRow)
End With
startCell = rg.getCellByPosition(0, 0)
startCell.String = pNewString
rg.FillAuto(0, 1)
rg.FillAuto(1, 1)
Next rgA
End Sub
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: [Solved] Regular Expression for empy cells
Lupp, thanks. Good to explore this route.
It's Microsoft marketing that tells you computers are qualified for non-technicians
W11 22H2 (build 22621), LO 7.4.2.3(x64)
W11 22H2 (build 22621), LO 7.4.2.3(x64)