My wish: Find a pattern '(ddd)' and replace ddd with the line number.
Example with ActionsScripot3:
...
trace('signature','(123)',...);
...
The idea is to replace '(123)' by the line number, because after editing text, the line number has changed.
What to find: [(][0-9]+[)]
Replace: (\i)
But \i is not the correct line number, it's the count of replacements.
With PHP, the problem doesn't exist because __LINE__ constant exist.
Find a formatted number and replace with the line numer
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Find a formatted number and replace with the line numer
Last edited by jmparatte on Sat Nov 26, 2011 7:40 am, edited 1 time in total.
It can't be done practically because there's no __LINE__ constant or other equivalent expression that returns the line number. If you absolutely had to fudge it, you could do it the following way, in three Replace operations.
Before starting, click Configure > Preferences > Editor and enable POSIX regular expression syntax. In the following examples, I've used the string "~~" on the assumption that it does not otherwise occur in your file. If it does, substitute another string.
Step 1 is to add the line number at the start of each line:
Find what: ^
Replace with: \i~~
Step 2 is to find the pattern "(ddd)" and replace "ddd" with the line number at the start of the line:
Find what: ([0-9]*)(~~.*\()[0-9]+(\).*)
Replace with: \1\2\1\3
Step 3 is to remove the line numbers at the start of each line:
Find what: [0-9]*~~
Replace with: (nothing)
Note however that if "(ddd)" occurs more than once per line this procedure will only replace the last occurrence.
Before starting, click Configure > Preferences > Editor and enable POSIX regular expression syntax. In the following examples, I've used the string "~~" on the assumption that it does not otherwise occur in your file. If it does, substitute another string.
Step 1 is to add the line number at the start of each line:
Find what: ^
Replace with: \i~~
Step 2 is to find the pattern "(ddd)" and replace "ddd" with the line number at the start of the line:
Find what: ([0-9]*)(~~.*\()[0-9]+(\).*)
Replace with: \1\2\1\3
Step 3 is to remove the line numbers at the start of each line:
Find what: [0-9]*~~
Replace with: (nothing)
Note however that if "(ddd)" occurs more than once per line this procedure will only replace the last occurrence.