[Dropped] Search and replace this

Discuss the word processor
Post Reply
Ciscokid2
Posts: 6
Joined: Wed Aug 14, 2013 1:19 am

[Dropped] Search and replace this

Post by Ciscokid2 »

I am trying to quickly edit several hundred email addresses in a text file. Here is a fictitious example.

I want to find and replace the first set of quotation marks and everything following up to and including the > ....(that is all of this " John.Smith"@here.ac.ca>) But the text between the " and the > is different in each address of course, so the text between would have to be taken out by a wildcard. Thanks for any ideas. I can't get my old retired brain around this.

John.Smith@here.ac.ca" John.Smith"@here.ac.ca>
Last edited by MrProgrammer on Sun Jan 07, 2024 1:09 am, edited 1 time in total.
Reason: Dropped: No attachment provided when requested -- MrProgrammer, forum moderator
OpenOffice 3.3.0 on Windows 7
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Search and replace this

Post by FJCC »

If there is one email address per line then

Code: Select all

".+>
with Regular Expressions selected in the More Options area, should do it.
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.
Ciscokid2
Posts: 6
Joined: Wed Aug 14, 2013 1:19 am

Re: Search and replace this

Post by Ciscokid2 »

No that did not work. Perhaps I left out too much of the lines. Let me put the whole thing in even though the first mail to part seems ok to leave.

"mailto:John.Smith@here.gc.ca" <"mailto:John.Smith"@here.gc.ca>

now, when I try “.+> to take out the second part " <"mailto:John.Smith"@here.gc.ca> nothing is found. I have selected regular expressions and tried selecting all file and part of it etc. Otherwise find and replace works properly for single words or " >. Those are all found just fine.

I really appreciate someone who can figure this out.

So to be clear, I want all of this to go " <"mailto:John.Smith"@here.gc.ca> including the space after the first set of quotations
OpenOffice 3.3.0 on Windows 7
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace this

Post by Zizi64 »

I really appreciate someone who can figure this out.
Please upload an ODF type sample file here without sensitive data, but with same structure as your original file.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Ciscokid2
Posts: 6
Joined: Wed Aug 14, 2013 1:19 am

Re: Search and replace this

Post by Ciscokid2 »

Thank you. I was being clear as possible when I said that out of the entire line I wanted this to go " <"mailto:John.Smith"@here.gc.ca> that is the entire part which runs to the end of the line. Thanks if you can figure it out.
OpenOffice 3.3.0 on Windows 7
User avatar
keme
Volunteer
Posts: 3699
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Search and replace this

Post by keme »

So, based on the examples I can make an educated guess:
  • Outer <> delimiters should persist when present.
  • The mail address within (or without) the <> needs adjustment as follows:
    • everything before the @ should be quoted as one item,
      • leading spaces if present
      • "mailto:" link protocol specifier if present.
      • recipient ID
    • Mail domain specifier after the @ should be kept as is, only stripping quotes where present.
Is that what you need?

Also, do you need to check for matched pairs (quotes and angle brackets) and/or null values in pre-existing entries so we only modify entries where the modification is relevant, or can we assume that source data is continuous and all well structured according to the above description?
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Search and replace this

Post by Lupp »

I'm somehow baffled now.
There is one format used with the protocol specifier "mailto:!" I know which allows to additionally include a plain name in a specific position excluded from interpretation by a pair straight of doublequotes. Examples for valid email addresses using the "mailto:" are:
mailto:me@somedomain.tld
mailto:<me@somedomain.tld>
mailto:""<me@somedomain.tld>
mailto:"Lupp"<me@somedomain.tld>
I did not research and study specifying sources, but concluded from examples my Thunderbird accepts. If I enter an ordinary email address in Open-/Libre-Office it is recognised (URL recognition enabled) and the link in the background gets automatically prefixed the "mailto:".

Thus an applicable syntax in RegEx should be (a few minor aspects aside):

Code: Select all

(^|\W)((mailto:)?[A-Z][A-Z0-9]+@[A-Z][A-Z0-9]{2,}\.[A-Z]{2,}(\W|$)|(mailto:"[^"]*"<)[A-Z][A-Z0-9]+@[A-Z][A-Z0-9]{2,}\.[A-Z]{2,}>)(\W|$)


Please note that the RegEx will not reject entries with a malformed mailto:"??" part ( a missing doublequote e.g.) if then comes a correct match.
I'm interested in leraning from the OQ how I misinterpreted the question and from everybody how to simplify, improve, or aptly critisize the RegEx.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Bill
Volunteer
Posts: 8932
Joined: Sat Nov 24, 2007 6:48 am

Re: Search and replace this

Post by Bill »

Please upload a sample file. I submitted a reply and deleted it because it was based on assumptions which may or may not be true. I will not make any more guesses without a sample to test.
AOO 4.1.14 on Ubuntu MATE 22.04
Ciscokid2
Posts: 6
Joined: Wed Aug 14, 2013 1:19 am

Re: Search and replace this

Post by Ciscokid2 »

Thank you. No, what you have is the correct format to delete....that is the sample....that is why the John Smith is in there in place of the elected politicians which would make up this large mailing list when edited with search and replace.

But there is a vitriol in this forum. I don't want to get in the line of fire. Just say it can't be done and we will leave it at that.

Thanks.
OpenOffice 3.3.0 on Windows 7
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace this

Post by Zizi64 »

...that is the sample...
A real ODF type file - uploaded it here: THAT IS the sample. The pictures, textual samples, and other attahments can give us SOME informations. But a real file give us ALL OF the available information about your/software issues...
Not needed to upload your original file with the original data. Change some data to "dummy" data, delete the sensitive data from a copy of your file, and then upload it here. The file size limit is 128 KiB in this Forum.
Last edited by Zizi64 on Wed Jun 20, 2018 10:15 am, edited 1 time in total.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Bill
Volunteer
Posts: 8932
Joined: Sat Nov 24, 2007 6:48 am

Re: Search and replace this

Post by Bill »

Ciscokid2 wrote:Just say it can't be done and we will leave it at that.
Search for: [:space:].+ works for me in the sample document I created, but since I don't have a sample of your document to test, it may or may not work or might just completely destroy your document.
AOO 4.1.14 on Ubuntu MATE 22.04
Post Reply