bookmarks
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- s_reynisson
- Posts: 940
- Joined: Tue May 06, 2003 1:59 pm
-
- Posts: 2459
- Joined: Sun Mar 02, 2003 9:22 pm
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
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
-
- Posts: 2459
- Joined: Sun Mar 02, 2003 9:22 pm
Configure | Preferences | EditorRoger wrote:is there any way to find an expression along a line, and then place a character at the beginning of a line?
[x] Use POSIX regular expression syntax
Search | Replace:
Find what: (.*expression.*)
Replace with: #\1
[x] Regular expression
Search | Replace: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?
Find what: (.*expression.*)
Replace with: \1#
[x] Regular expression
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
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
Not completely correct. It removes all ' wherever they occur in the line.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.
If you only want to replace those at the beginning of the line, use
Code: Select all
^'
Code: Select all
'
-
- Posts: 2459
- Joined: Sun Mar 02, 2003 9:22 pm
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 ".*".Roger wrote:Find What
(.*rem*)
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.)
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 wrote:Find What
(*rem*)
Replace With
'\1
- s_reynisson
- Posts: 940
- Joined: Tue May 06, 2003 1:59 pm
I like this one http://www.regular-expressions.info/tutorial.html
and also lot's of links here http://www.regularexpression.info/
Links http://www.regxlib.com/
And of course your friendly software maker
But Friedl is the best
and also lot's of links here http://www.regularexpression.info/
Links http://www.regxlib.com/
And of course your friendly software maker
But Friedl is the best
Then I open up and see
the person fumbling here is me
a different way to be
the person fumbling here is me
a different way to be
-
- Posts: 2459
- Joined: Sun Mar 02, 2003 9:22 pm
- s_reynisson
- Posts: 940
- Joined: Tue May 06, 2003 1:59 pm
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
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:Bit it's not a tutorial!s_reynisson wrote:But Friedl is the best
Then I open up and see
the person fumbling here is me
a different way to be
the person fumbling here is me
a different way to be
-
- Posts: 2459
- Joined: Sun Mar 02, 2003 9:22 pm
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.
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 ;)