I am using the latest version of Keyboard Maestro and was wondering how to search the clipboard for the paragraph mark and replace all instances with two paragraph marks? Thanks.
Try it in your favorite text editor.
Select some text, and run the macro.
Oh, I've set it to find 1 or more carriage returns (or newlines) and turn them into 2 to regularize the output.
You can remove the + sign from the regular expression to replace each and every carriage return (or newline) with two.
That worked perfectly. Thanks!
This is exactly what I was looking for! Thank you so much!
Anyone advise. Got this far but cannot get rid of first and last paragraph marks using regex.
If this is MS Word, then use this AppleScript, which I copied from here, page 119:
(FTP links don’t seem to work here.)
What regex and app are you using?
When asking for help with regular expressions it's a good idea to post the actual text and regex you're working with.
It's also a good idea to say what application you're working in, because it sometimes makes a great deal of difference in the approach used for the problem.
Tom's method is nice, because it works directly with Word to get the job done.
For something more generic try this macro:
NOTE → You need to select the text you're working with prior to running the macro.
Apologies for confusing.
Text shows what is left after regex in textedit BUT copied and pasted into Word in order for me to see what the white spaces beginning and ending were. Below is original
and below is result so far
So by pasting into Word I know that leading and trailing white spaces are paragraph characters but a) cannot find specifically the regex symbol for paragraph mark and b) how to delete leading and trailing occurrences.
Well, I showed you how to do exactly that.
You still haven’t provided the actual test-case text and the regular expression (or macro) involved.
Without seeing those it’s hard to tell where you’ve gone wrong.
thought that pertained to Word - just tried and great - works. Also, streamlined other bits.
What is the vertical line after the first \s “|” called so I can look it up?
“|” is often called the bar or “or” symbol and its function in a regular expression is alternation (a logical OR).
Since it is the pipe symbol in shell scripting it is sometimes referred to as that in regex (although the meaning is very different).
Alternation – alternation allows several subexpressions to be tested at a given point. Each subexpression is called an alternative.
* From “Mastering Regular Expressions” by Jeffrey Friedl.
This pattern will find lines beginning with “Chris” OR “Christopher”
Whups – I miswrote that.
The given expression will find lines that:
Christopher and 1 or more characters.
I meant to write it this way:
This will find lines that start with
Christopher and contain 1 or more additional characters.
I have a question - I’m trying to delete the lines in document that contain only 1 or more spaces (typically just one). The “Trim Whitespace” in “filter variable” does not take them out. Any hints?
I’m using the macro: Author.@cfriend PURPOSE: Remove blank lines between lines of highlighted text
An example of the type of text that I am trying to clean up is. This happens sometimes when I paste text from an Office document into Apple Mail, even if I paste as plain text.
Test test text
Test Test test text
TestTest test text
Test Test test text
This RegEx should do the trick:
Here's a example macro. Adjust as needed:
MACRO: Remove Blank Lines (Zero or more white space)
VER: 1.0 2017-02-18 ~~~
THANK YOU. Works perfectly. I speak a few foreign languages (not programming) and learning Applescript and Expressions seem a lot like learning a new language to me! I appreciate your help very much.