bookmarks

General questions about using TextPad

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

Post Reply
gcotterl
Posts: 238
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

bookmarks

Post by gcotterl »

'05' can occur anywhere in a row. How do I bookmark only rows that START with '05'?

Thanks,

Gary
User avatar
s_reynisson
Posts: 940
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

By using a regular expression:
Find ^05
Tick Regular expression
Press Mark All
I have used POSIX regular expression syntax, which can be selected
from the Editor page of the Preferences dialog box.
HTH
Then I open up and see
the person fumbling here is me
a different way to be
gcotterl
Posts: 238
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

bookmarks

Post by gcotterl »

Great! That worked!

Now, how do I bookmark rows containing '(1' starting in position 53?
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find: ^.{52}\(1
[x] Regular expression
Mark All

Configure | Preferences | Editor
[x] Use POSIX regular expression syntax
Roger
Posts: 5
Joined: Mon Feb 16, 2004 2:14 pm

Post by Roger »

I can use a regular expression to find a character along a line and place a bookmark on that line. I can also find a character along a line and replace it with a character or expression.
However, is there any way to find an expression along a line, and then place a character at the beginning of a line?
Similarly, is there any way to find an expression along a line and place a character at the end of the same line?

Thanks

Roger
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Roger wrote:is there any way to find an expression along a line, and then place a character at the beginning of a line?
Configure | Preferences | Editor
[x] Use POSIX regular expression syntax

Search | Replace:
Find what: (.*expression.*)
Replace with: #\1
[x] Regular expression
Roger wrote:Similarly, is there any way to find an expression along a line and place a character at the end of the same line?
Search | Replace:
Find what: (.*expression.*)
Replace with: \1#
[x] Regular expression
Roger
Posts: 5
Joined: Mon Feb 16, 2004 2:14 pm

Post by Roger »

Ben

Fantastic, Many Thanks

My compiler treats rem, ' (single apostrophe), and ; (semicolon) as directives to ignore any statements following them.

I can now write lines as follows

' code ; rem any other remarks (for lines not to be compiled)
code ; rem any other remarks (for lines to be compiled)

Open up code file in textpad
Find What
(.*rem*)
reg exp
Mark All

This puts up bookmarks as visual indicators of lines to be toggled, (save file as workspace to retain)

Find What
(*rem*)
Replace With
'\1
reg exp
Replace All

Places ' at beginning of bookmarked lines. Code can be compiled and simulated without eg real time code statements.

Find What
'
Replace With
(box is blank)
reg exp
Replace All

Removes all ' at beginning of bookmarked lines. Code can be compiled and run at full speed.

The rem statements are preserved and not actually replaced during these operations.

Not quite single button multiple bookmarked line comment/uncomment, but it will do me in the meantime.

Thanks all. Hope it is useful.

Roger
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

ind What
'
Replace With
(box is blank)
reg exp
Replace All

Removes all ' at beginning of bookmarked lines. Code can be compiled and run at full speed.
Not completely correct. It removes all ' wherever they occur in the line.
If you only want to replace those at the beginning of the line, use

Code: Select all

^' 
instead of just

Code: Select all

'
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Roger wrote:Find What
(.*rem*)
If you're searching without replacing, you don't need to capture the found text with parentheses (to be referred to as "\1", etc., in the replacement text). And you don't need to find the "any context" with ".*".

Note that the regex to find any string is ".*", not "*". Regexes are not like wild-card expressions (although wild-card expressions are a very limited form of regular expressions, with a non-standard syntax). (And regexes are a very extended form of regular expressions; in fact, they're much more than regular.)
Roger wrote:Find What
(*rem*)
Replace With
'\1
That should be "(.*rem.*)". And you probably want something like "(.*\<rem\>.*)" (or something fancier, depending on the syntax of your language) to avoid picking up identifiers like "trembler".
Roger
Posts: 5
Joined: Mon Feb 16, 2004 2:14 pm

Post by Roger »

Thanks for that Mudguard, you can tell I'm new to regular expressions. Sorry about the typo, Ben, and thanks for the clarification.

Can anyone recommend a good tutorial on regular expressions? The Help File in TextPad is a bit steep for a newbie.

Thanks

Roger
User avatar
s_reynisson
Posts: 940
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

Then I open up and see
the person fumbling here is me
a different way to be
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

s_reynisson wrote:But Friedl is the best
Bit it's not a tutorial!
User avatar
s_reynisson
Posts: 940
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

Friedl's book can broken down into two parts:
1. Regex's, chapters 1 to 6
2. Language specific regex's, chapters 7 to 9 (Perl, Java and .Net)
Chapters 1 to 3 are indeed for the "novice", I personally reccomend them as a tutorial
and a practical one while you're at it, they are full of real-work-related examples ;)
ben_josephs wrote:
s_reynisson wrote:But Friedl is the best
Bit it's not a tutorial!
Then I open up and see
the person fumbling here is me
a different way to be
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I just checked. It was at the bottom of a very tall pile. You're right. I'd forgotten that it started at the beginning. Excuse: I haven't looked at it for ages. (It's the ancient first edition, which stops after ch. 7.)

Apologies. Also to Mr Friedl.
s_reynisson wrote:Chapters 1 to 3 are indeed for the "novice", I personally reccomend them as a tutorial
and a practical one while you're at it, they are full of real-work-related examples ;)
Post Reply