Hi,
I did not think this would be difficult, but it was difficult for me. How do I replace a paragraph marker^p with " ^p? I ended up using another text editor but I want to use Textpad. I would appreciate any guidance,
D
Replacing Paragraph Marker
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Remember that TextPad is a text editor. There is no such thing as a paragraph marker in plain text (unless you mean the paragraph sign: ¶ or §). Do you mean the markers at the ends of paragraphs in a word processing document produced by a program such as Microsoft Word? MS Word allows you to search for these markers using the idiosyncratic pattern ^p. If you save a Word document as a plain text file, you will find that the ends of paragraphs are converted into end-of-line markers (by default on a PC, a pair of characters: <CR> (carriage return), <LF> (line feed)). End-of-line markers are often called, generically, new lines.
You can search for new lines in TextPad using regular expressions. You can use any of the patterns ^, $ or \n. The patterns ^ and $ are anchors; that is, they match at a new line without matching any characters. ^ matches at the beginning of a line; $ matches at the end of a line. So if you replace either of them with something, that something replaces no characters; it is just inserted. The pattern \n matches the new line itself; so if you replace it with something, that something replaces the new line. Thus you can remove new lines, joining adjacent lines together.
It is not clear from your message exactly what you are trying to do. But if you want to insert a double quote at the end of each line, you can use Search | Replace:
You can search for new lines in TextPad using regular expressions. You can use any of the patterns ^, $ or \n. The patterns ^ and $ are anchors; that is, they match at a new line without matching any characters. ^ matches at the beginning of a line; $ matches at the end of a line. So if you replace either of them with something, that something replaces no characters; it is just inserted. The pattern \n matches the new line itself; so if you replace it with something, that something replaces the new line. Thus you can remove new lines, joining adjacent lines together.
It is not clear from your message exactly what you are trying to do. But if you want to insert a double quote at the end of each line, you can use Search | Replace:
Find what: $
Replace with: "
[x] Regular expression
Great Explanation
Ben,
Thank you. That worked perfectly. I asked this question because I came across an interesting process to find empty folders.
DIR /AD/B/S | SORT /R > EMPTIES.BAT
The resulting file required adding RD" to the beginning and " to the end. The article from PCMag, http://www.pcmag.com/article2/0,1759,805015,00.asp suggested:
'using Find and Replace to search for ^p (which represents the paragraph mark) and replace it with "^pRD " '
Have a great day,
d
Thank you. That worked perfectly. I asked this question because I came across an interesting process to find empty folders.
DIR /AD/B/S | SORT /R > EMPTIES.BAT
The resulting file required adding RD" to the beginning and " to the end. The article from PCMag, http://www.pcmag.com/article2/0,1759,805015,00.asp suggested:
'using Find and Replace to search for ^p (which represents the paragraph mark) and replace it with "^pRD " '
Have a great day,
d
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
The following assumes you are using POSIX regular expression syntax:
Using Search | Replace:Configuration | Preferences | Editor
[x] Use POSIX regular expression syntax
This works because matches are leftmost (in this case, each match begins at the beginning of a line) and longest (in this case, each match ends at the end of a line). The use of + rather than * causes the pattern not to match empty lines.Find what: (.+)
Replace with: rd "\1"
[x] Regular expression
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Diek had already improved on the version in PCMag's rather poor article by adding quotes. That article is not the most helpful. It suggests that the user should use MS Word to edit a text file. Wouldn't encourage me to read (far less, buy) the magazine...
To clarify my explanation above:
To clarify my explanation above:
is equivalent toFind what: (.+)
Replace with: rd "\1"
Find what: ^(.+)$
Replace with: rd "\1"