Replace the 1st (or 3rd) INSTANCE OF / on a line

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
no.cache
Posts: 165
Joined: Thu May 15, 2003 2:52 pm

Replace the 1st (or 3rd) INSTANCE OF / on a line

Post by no.cache »

Hi guys. I'm trying to locate either the 1st Instance or the 3rd Instance of / on a line, and replace the character immediately following with a carrier return (\n).

2 EXAMPLES (both block left)

- - - - - - - - - - - - - - - - - - - - - - - - - -
www.1111.com/aaaaaaa.OOOOO.html
becomes
www.1111.com/(carrier return)
aaaaaaa.OOOOO.html

- - - - - - - - - - - - - - - - - - - - - - - - - -
http://www.2222.com/bbbbbbb.html
becomes
http://www.222.com/(carrier return)
bbbbbbb.html

Thanks everyone.
Trump.
Jesus wept.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Do you really want to find the last slash on the line?

Do you want to insert a newline sequence (either Windows style CR,LF (carriage return, line feed) or Unix style LF (line feed)), rather than a lone CR?

Do you want to insert a newline, as your examples (ignoring the typo) indicate, rather than replace anything with one.

If so, try this:
Find what: ^.*/
Replace with: \0\n
User avatar
no.cache
Posts: 165
Joined: Thu May 15, 2003 2:52 pm

Post by no.cache »

Hi Ben and thank you once again.

I'm modifying my original request to search every FF Bookmark entry containing the line example:

Code: Select all

<DT><H3 ADD_DATE="1412102482" LAST_MODIFIED="1412181470">WikiBOOKS &amp; WikiPEDIA BOOKS</H3>
and insert a newline (\n) immediately after the first > that follows the word MODIFIED (for which there is only one instance per bookmark). The result should look like this when I look at it in Textpad:

Code: Select all

<DT><H3 ADD_DATE="1412102482" LAST_MODIFIED="1412181470">
WikiBOOKS &amp; WikiPEDIA BOOKS</H3>
I realize the output is illegal for HTML purists but this is for my own private use. :P

Thanks Ben.
Trump.
Jesus wept.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what: MODIFIED[^>]*>
Replace with: $0\n
User avatar
no.cache
Posts: 165
Joined: Thu May 15, 2003 2:52 pm

Post by no.cache »

It doesn't work Ben. It strips out everything after LAST_ and replaces it with $0\n. It does however put that Title data on a new line. :wink:
Trump.
Jesus wept.
User avatar
no.cache
Posts: 165
Joined: Thu May 15, 2003 2:52 pm

Post by no.cache »

Put an easier way, I'm not deleting anything. I am merely inserting a \n (newline) at a position relative to the word MODIFIED.
Trump.
Jesus wept.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

It does work.

I see you are using a very old version of TextPad, whose regex support is very different from and very much weaker than the current version's. Much that can be done in the current version cannot be done in previous versions.

Try this:
Find what: MODIFIED[^>]*>
Replace with: \0\n
I cannot test this.
User avatar
no.cache
Posts: 165
Joined: Thu May 15, 2003 2:52 pm

Post by no.cache »

ben_josephs wrote:I see you are using a very old version of TextPad, whose regex support is very different from and very much weaker than the current version's. Much that can be done in the current version cannot be done in previous versions. I cannot test this.
Ah. Ben, how stable is the latest version? I ask because when I attempted using a newer version many months ago it kept crashing.
Trump.
Jesus wept.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I'm running version 7.4.0 (the latest is 7.5.1). I use TextPad very heavily. I currently have 18 sessions running, with many documents open in each. I don't recall when it last crashed. I'm not sure it ever did.

Did my suggestion work?
User avatar
no.cache
Posts: 165
Joined: Thu May 15, 2003 2:52 pm

Post by no.cache »

Okay Ben, I'll upgrade it to 7.4 but you're vacuuming my house if it crashes!! juuuuuust kidding
Trump.
Jesus wept.
Post Reply