OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Search & Replace difficulties

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
BRG
Power User
Power User


Joined: 30 Jun 2008
Posts: 68
Location: Wheaton, Maryland

PostPosted: Wed Mar 04, 2009 11:45 am    Post subject: Search & Replace difficulties Reply with quote

I like OOo Writer in general, but there are two things I wish worked differently, and since they are very much unrelated to each other I don't want to put them in a single post. So this post will address the one that I find the most serious. The search & replace feature is almost impossible to use for anything involving more than a literal search. It's the one way Microsoft Word beats Writer hands down. Word lets you use "Special" and you can select "any digit" or "any letter" for example. In the replace you can put in "result of the search." A lot of this can be done in Writer with "regular expressions," but the syntax of the REs is so opaquely explained that I have never even once been able to make a search and replace using REs work -- this sounds worse than it is, because after about a half dozen or so disastrous attempts I just gave up, and haven't even tried. Now, what I do is one of two things: I copy the document to a USB thumb drive and take it somewhere where the computer has Word (which may delay the whole process by 24 hours!), or I save the file as a text file and write a FORTRAN program to make the substitution, which requires compiling, debugging, and all that entails! I'm not an idiot -- I was a programmer for over 20 years, which is why I'm able to do the second of these two options -- but I shouldn't need to do these things to use a word processor. Apparently people who have spent years in a Unix environment get familiar with RE syntax, but I simply have not got that background.

OOo is open-source, but it's a far more complex program than I'd want to get into to modify the code, so a Word-like interface for Search & Replace is probably as high on my wish list as anything could possibly be. If anyone could fix this up, he/she would have my undying gratitude.
Back to top
View user's profile Send private message Send e-mail
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Thu Mar 05, 2009 12:08 am    Post subject: Re: Search & Replace difficulties Reply with quote

BRG wrote:
select "any digit" or "any letter" for example. In the replace you can put in "result of the search."


[a-z], [A-Z], [:alpha:]; [0-9], [:digit:]; &


BRG wrote:
save the file as a text file and write a FORTRAN program to make the substitution

Or you could use command line Perl or a Perl script, an editor like Bluefish or sed or you could even use Python through the API:
http://www.devshed.com/c/a/Python/Python-and-OpenOfficeorg which even I as a past programmer with only about 5 years working experience of Fortran managed to fathom out. (Incidentally I never considered Fortran for the job.)
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
BRG
Power User
Power User


Joined: 30 Jun 2008
Posts: 68
Location: Wheaton, Maryland

PostPosted: Thu Mar 05, 2009 2:00 am    Post subject: Response to Robert Tucker Reply with quote

"you could use command line Perl or a Perl script, an editor like Bluefish or sed or you could even use Python through the API"
Why would I even consider using a language like Perl, which I would have to learn anew from scratch? I have about 30 years of experience with FORTRAN and so I think mainly in that language when trying to come up with algorithms.

(And the fact that you would not consider that language is just a sign that unlike me, you may have more familiarity with other languages, so it might be easier for you to write in them.)

I've used a few other languages in my life (PL/I, ALGOL, and even some APL) but the total number of programs I've written in those languages in the past 15 years is approximately zero.

In the time it would take me to learn enough Perl to use it confidently, I could have certainly edited 50 or 60 files using FORTRAN programs, even with the problems of compiling and debugging.
Back to top
View user's profile Send private message Send e-mail
BRG
Power User
Power User


Joined: 30 Jun 2008
Posts: 68
Location: Wheaton, Maryland

PostPosted: Thu Mar 05, 2009 2:50 am    Post subject: Re: Search & Replace difficulties Reply with quote

Robert Tucker wrote:
select "any digit" or "any letter" for example. In the replace you can put in "result of the search."

[a-z], [A-Z], [:alpha:]; [0-9], [:digit:]; &



For those, your examples work. Your giving the ampersand is even helpful, as it just made my first successful search & replace involving a RE work!
But I had only meant these as a very partial list of the specials in Word, not a complete one. And when I've seen the instructions for inserting or deleting line breaks, the Word interface works much more easily. A "manual line break" or "paragraph mark" in Word is a character which can be put into a search string or a replace string. In Writer, this capability, as far as I've been able to determine, simply does not exist.

Suppose I wanted to insert a line break between </td> and <td> wherever this sequence occurs. In Word this is a single search and replace:

Search for: </td><td>
Replace with: </td>^p</td>

where in fact I would not write "^p" but go to a menu, select "paragraph mark", and Word would insert the ^p so I don't have to remember all those codes. (I have not remembered most of them!)
Back to top
View user's profile Send private message Send e-mail
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Thu Mar 05, 2009 5:54 am    Post subject: Re: Search & Replace difficulties Reply with quote

BRG wrote:


Search for: </td><td>
Replace with: </td>^p</td>

where in fact I would not write "^p" but go to a menu, select "paragraph mark", and Word would insert the ^p so I don't have to remember all those codes.

But when does an experienced programmer or other IT professional use a word-processor to edit an html file?

I agree OpenOffice's "awkwardness" with paragraphs can be annoying but at the same time I can't think of any examples off hand where one needs to edit across paragraphs in a word-processor other than to make sure there's only two (or whatever) paragraph breaks between paragraphs.

You have found the "List of Regular Expressions" in the Help files?
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Thu Mar 05, 2009 6:03 am    Post subject: Re: Response to Robert Tucker Reply with quote

BRG wrote:
"you could use command line Perl or a Perl script, an editor like Bluefish or sed or you could even use Python through the API"
Why would I even consider using a language like Perl,

You only need to learn command line substitutions, things like:

Code:
perl –p –e 's/old/new/g;'


which would replace "old" by "new" throughout the text file.
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Thu Mar 05, 2009 6:07 am    Post subject: Re: Search & Replace difficulties Reply with quote

BRG wrote:
Your giving the ampersand is even helpful, as it just made my first successful search & replace involving a RE [i][b]work

You may find the fact that since 2.4.0 you can also use back-references:

http://www.oooninja.com/2007/12/backreferences-in-replacements-new.html
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
BRG
Power User
Power User


Joined: 30 Jun 2008
Posts: 68
Location: Wheaton, Maryland

PostPosted: Thu Mar 05, 2009 6:23 am    Post subject: Re: Search & Replace difficulties Reply with quote

Robert Tucker wrote:


But when does an experienced programmer or other IT professional use a word-processor to edit an html file?


What would you use? Actually because of Writer's difficulties, I mostly use Notepad.

I certainly would not use the specialized html programs like DreamWeaver; they cost an arm and a leg and they generate very dirty html intended to provide for all options. I think I can write cleaner HTML than any program I've seen.

Quote:

I agree OpenOffice's "awkwardness" with paragraphs can be annoying but at the same time I can't think of any examples off hand where one needs to edit across paragraphs in a word-processor other than to make sure there's only two (or whatever) paragraph breaks between paragraphs.


Well, here's what I do. Someone gives me a file in .xls form. I open it in Calc and save it as a .csv file, which I then edit as text. I convert the semicolons to something like

</td> <td id="whatever">

or even to

</td></tr> <tr><td id="


where the next column becomes my label.
Then I want to insert a line break between </td> and <td> or between </tr> anmd <tr> because I think it looks cleaner.

Does this make sense to you? Because I want to use constructs like "rowspan" and "colspan" to create a properly-formatted table (the spreadsheets sent me aren't set up the way I want to do my HTML tables) I need to edit the files. (To see the type of html I need to produce, look at http://phone.net46.net/philadelphia-city/latealpha.html as a recent example.)


Quote:
You have found the "List of Regular Expressions" in the Help files?


Yes, that is exactly the thing I was referring to when I said earlier that the whole RE syntax is terribly opaque.
Back to top
View user's profile Send private message Send e-mail
BRG
Power User
Power User


Joined: 30 Jun 2008
Posts: 68
Location: Wheaton, Maryland

PostPosted: Thu Mar 05, 2009 6:28 am    Post subject: Re: Search & Replace difficulties Reply with quote

Robert Tucker wrote:

You may find the fact that since 2.4.0 you can also use back-references:

http://www.oooninja.com/2007/12/backreferences-in-replacements-new.html



I just looked at that post. It is a clear example of just how obscure and incomprehensible the RE syntax is. I might wery well want to do exactly that sort of thing. But I can't make head or tail of how you do what is being done there. So that's the kind of things I write FORTRAN programs to do.
Back to top
View user's profile Send private message Send e-mail
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Thu Mar 05, 2009 7:31 am    Post subject: Re: Search & Replace difficulties Reply with quote

BRG wrote:
Robert Tucker wrote:


But when does an experienced programmer or other IT professional use a word-processor to edit an html file?


What would you use? Actually because of Writer's difficulties, I mostly use Notepad.

On Linux I would use Bluefish (it's good but can be very slow on large files, i.e. tens or hundreds of thousands of lines long) but I believe Notepad++ is very popular on Windows and handles regular expressions. There's a list of free editors here:

http://www.thefreecountry.com/webmaster/htmleditors.shtml
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group