Search and replace this

Discuss the word processor

Search and replace this

Postby Ciscokid2 » Wed Jun 13, 2018 6:21 pm

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>
OpenOffice 3.3.0 on Windows 7
Ciscokid2
 
Posts: 6
Joined: Wed Aug 14, 2013 1:19 am

Re: Search and replace this

Postby FJCC » Wed Jun 13, 2018 6:55 pm

If there is one email address per line then
Code: Select all   Expand viewCollapse view
".+>

with Regular Expressions selected in the More Options area, should do it.
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6803
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Search and replace this

Postby Ciscokid2 » Wed Jun 13, 2018 9:24 pm

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
Ciscokid2
 
Posts: 6
Joined: Wed Aug 14, 2013 1:19 am

Re: Search and replace this

Postby Zizi64 » Wed Jun 13, 2018 9:46 pm

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; LO4.4.7, LO6.1.1 on Win7x64Prof.
PortableApps, winPenPack: LO3.3.0-LO6.1.2 and AOO4.1.5
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.
User avatar
Zizi64
Volunteer
 
Posts: 7357
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace this

Postby MrProgrammer » Thu Jun 14, 2018 5:12 am

Ciscokid2 (first post) wrote:John.Smith@here.ac.ca" John.Smith"@here.ac.ca>
Ciscokid2 (second post) wrote:"mailto:John.Smith@here.gc.ca" <"mailto:John.Smith"@here.gc.ca>
Ciscokid2 wrote:I want to find and replace the first set of quotation marks and everything following up to and including the >

You've given us two different examples, one with two quotation marks, one with four quotation marks, one with mailto: one without that.

Which is it? Or do you have both formats?

In the second case, removing (your words) "the first set of quotation marks and everything following up to and including the >" leaves nothing! Is that really what you want?

Attach a document demonstrating the situation (remove confidential information then use Post Reply, not Quick Reply, and don't attach a picture instead of the document itself). Provide enough examples showing what is desired so that there can be no doubt about how to handle each case. I suspect this is simple to do with [Tutorial] Text to Columns but I can't offer more advice without knowing your real data, not some fictitious example, and precisely what result is desired.
Mr. Programmer
AOO 4.1.5 Build 9789 on Mac OS 10.11.6.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Volunteer
 
Posts: 3499
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Search and replace this

Postby Ciscokid2 » Thu Jun 14, 2018 1:52 pm

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
Ciscokid2
 
Posts: 6
Joined: Wed Aug 14, 2013 1:19 am

Re: Search and replace this

Postby keme » Thu Jun 14, 2018 2:42 pm

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
keme
Volunteer
 
Posts: 2977
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Search and replace this

Postby Lupp » Thu Jun 14, 2018 4:58 pm

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   Expand viewCollapse view
(^|\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 6.1 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Let's create a powerful UFO: United Free Office!
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2096
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Search and replace this

Postby MrProgrammer » Thu Jun 14, 2018 5:35 pm

Ciscokid2 wrote:No that did not work.
"It didn't work" isn't helpful in the forum because it tells us what did not happen. Please never use that phrase in a post. We need to know what the data looked like beforehand, exactly what actions you took, what the data looked like afterward, and what you expected to happen.

Ciscokid2 wrote:I was being clear as possible when …
Reading the posts from several volunteers, you should be able to tell that your explanation of the situation has been poor. You risk having people ignore your posts unless you improve them in the future. We're providing free advice, and I, at least, hesitate to waste my time on people who cannot describe the problem unambiguously.

You failed to attach your actual data so I will have to guess at a procedure, and this is my final post in this topic. Experience tells me that often ficticious data does not illustrate the real situation and solutions created for it do not scale to the actual data. Try these two steps:
• Remove all quotation marks from the data using Edit → Find&Replace
• Use Data → Text to Columns → Separated by → Space → First field = TextAll other fields = Hide → OK

I encourage you to read the tutorial I linked above before using Text to Columns. But if you use that feature and make a mess of your data, don't forget you can use Edit → Undo to fix the damage. If you need additioanl assistance with Find&Replace or Text to Columns read about those topics in Help → Index or in User Guides (PDF) or search for topics about them in the Calc Forum. Bye.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
Last edited by MrProgrammer on Thu Jun 14, 2018 9:21 pm, edited 1 time in total.
Mr. Programmer
AOO 4.1.5 Build 9789 on Mac OS 10.11.6.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Volunteer
 
Posts: 3499
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Search and replace this

Postby Bill » Thu Jun 14, 2018 8:48 pm

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.5 and LO 6.0.3.2 on Manjaro MATE
Bill
Volunteer
 
Posts: 6898
Joined: Sat Nov 24, 2007 6:48 am

Re: Search and replace this

Postby Ciscokid2 » Tue Jun 19, 2018 4:55 pm

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
Ciscokid2
 
Posts: 6
Joined: Wed Aug 14, 2013 1:19 am

Re: Search and replace this

Postby Zizi64 » Tue Jun 19, 2018 8:37 pm

...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; LO4.4.7, LO6.1.1 on Win7x64Prof.
PortableApps, winPenPack: LO3.3.0-LO6.1.2 and AOO4.1.5
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.
User avatar
Zizi64
Volunteer
 
Posts: 7357
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Search and replace this

Postby Bill » Wed Jun 20, 2018 9:54 am

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.5 and LO 6.0.3.2 on Manjaro MATE
Bill
Volunteer
 
Posts: 6898
Joined: Sat Nov 24, 2007 6:48 am


Return to Writer

Who is online

Users browsing this forum: robleyd and 22 guests