Given those requirements, I've developed the below Macro.
Note the following:
- I revised your post to put your source data into a Code Block, so that ALL characters are properly maintained.
- In the future, please put ALL source data in a Code Block, and also ALL results in a Code Block.
- This is the data I used.
- I noticed you have a lot of spaces in your source text. I think I have properly accounted for one or more spaces or tabs using the
\h
RegEx metacharacter. - I have assumed that your statement "might be missing" to mean that the entire lines containing either the Phone or Website would be missing. If this is incorrect, then the RegEx will need adjusting.
- RegEx:
(?mi)Address\h+(\w+)\h+(\w+)\n\h*(\d+ \w+) (\w+) (\w+)\n(?:Phone\h+(.+)\n)?(?:Website\h+(.+)\n)?lat\. long\.\h+(.+)
.
For RegEx details, explanation, and test, see:
https://regex101.com/r/Vovw15/1/
Please let us know if this works for you, or you have further issues or questions.
Example Output
Data WITH Phone and WebSite Lines
Data WITHOUT Phone and WebSite Lines
MACRO: Extract Address, Phone, and Web Site from Text [Example]
#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/f/3/f377965be1b6f097f1fba975112a4db5e6a3530a.kmmacros">Extract Address- Phone- and Web Site from Text [Example].kmmacros</a> (13 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**
---
### ReleaseNotes
Author.@JMichaelTX Requesting Post by @Mudness
**PURPOSE:**
* **Extract Address and Optionally Phone & WebSite from Clipboard**
**REQUIRES:**
1. **KM 8.2+**
2. **macOS 10.11.6 (El Capitan)**
**==NOTICE: This macro/script is just an _Example_==**
* It has had very limited testing.
* You need to test further before using in a production environment.
* It does not have extensive error checking/handling.
* It may not be complete. It is provided as an example to show you one approach to solving a problem.
**How To Use**
1. First, complete Macro Setup as instructed below.
2. Select Text that contains Address etc
3. Trigger this macro.
**MACRO SETUP**
* **Carefully review the Release Notes and the Macro Actions**
* Make sure you understand what the Macro will do.
* You are responsible for running the Macro, not me. ??
.
1. Assign a Trigger to this maro..
2. Move this macro to a Macro Group that is only Active when you need this Macro.
3. ENABLE this Macro.
.
* **REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:**
(all shown in the magenta color)
* For Production Use, ENABLE the COPY Aciton,
and DISABLE the Set Clipboard Action
* For Testing, enter your sample source text into the Set Clipboard Action
TAGS: @RegEx @Extract @Address @OptionalCaptureGroups
USER SETTINGS:
* Any Action in _magenta color_ is designed to be changed by end-user
ACTION COLOR CODES
* To facilitate the reading, customizing, and maintenance of this macro,
key Actions are colored as follows:
* GREEN -- Key Comments designed to highlight main sections of macro
* MAGENTA -- Actions designed to be customized by user
* YELLOW -- Primary Actions (usually the main purpose of the macro)
* ORANGE -- Actions that permanently destroy Variables or Clipboards,
OR IF/THEN and PAUSE Actions
**USE AT YOUR OWN RISK**
* While I have given this limited testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
* If you have any doubts or questions:
* **Ask first**
* Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.
---
![image|523x1453](upload://4mkbmGSbV1qAu36DjFY1aCPTvp2.png)