Page 1 of 1
Replace the 1st (or 3rd) INSTANCE OF / on a line
Posted: Fri Mar 06, 2015 6:32 pm
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.
Posted: Fri Mar 06, 2015 10:43 pm
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
Posted: Thu Jun 04, 2015 8:12 pm
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 & 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 & WikiPEDIA BOOKS</H3>
I realize the output is illegal for HTML purists but this is for my own private use.
Thanks Ben.
Posted: Thu Jun 04, 2015 10:11 pm
by ben_josephs
Find what: MODIFIED[^>]*>
Replace with: $0\n
Posted: Thu Jun 04, 2015 10:53 pm
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.

Posted: Thu Jun 04, 2015 10:59 pm
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.
Posted: Fri Jun 05, 2015 9:02 am
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.
Posted: Fri Jun 05, 2015 5:24 pm
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.
Posted: Fri Jun 05, 2015 7:29 pm
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?
Posted: Fri Jun 05, 2015 9:47 pm
by no.cache
Okay Ben, I'll upgrade it to 7.4 but you're vacuuming my house if it crashes!! juuuuuust kidding