About
JEdit - Search and Replace example
Articles Related
Examples
Using the complete matched text
The goal is here to add quotes and to have the text in lower-case.
arlau002
MAHAN001
Search for:
[a-zA-Z0-9]*
Replace with:
"'"+_0.toLowerCase()+"',"
where:
- _0 is the java text object to be replaced
Result:
'arlau002',
'mahan001',
Using matched subexpressions
As regular expressions are enabled, _1 - _9 can be used and they contain the values of matched subexpressions. Matched subexpressions are defined with two parenthesis.
Input file:
basename.exe
cut.exe
Search for:
([a-z]*){1}(.){1}(exe){1}
Replace with:
"|"+_1+"|"+_3+"|"
where:
- _1 is the first matched subexpression ([a-z]*){1}
- _2 is the second (.){1}
- _3 is the third (exe){1}
Output:
|basename|exe|
|cut|exe|
Suppress file attributes from a dir output
Output of the utility directory of Endeca
04/17/2012 10:40 AM 24,064 cut.exe
04/17/2012 10:40 AM 16,384 false.exe
We want to suppress the file attributes (date, time and size).
Regular expression
(.*\s){1}([a-z]*\.exe){1}
Replace with “Return value of a bean shell”
_2
Result:
cut.exe
false.exe
Get the PID of the ttStatus output
To be able to close the connection, you need to kill the process.
One way to get the PID of the process is to call the utility ttstatus and to take only the server process.
Server 20529 0x0000000001e6c8a0 DI_OBIEE_AIRLINE_AGG@DI_TT_CAC 4
(Client Information: pid: 10824; IPC: TCP/IP;
Node: HI-LAPTOP-NGD (192.168.71.33))
Server 21452 0x00000000008bb8a0 DI_OBIEE_AIRLINE_AGG@DI_TT_CAC 5
(Client Information: pid: 10824; IPC: TCP/IP;
Node: HI-LAPTOP-NGD (192.168.71.33))
Server 3428 0x000000000198f8a0 DI_OBIEE_AIRLINE_AGG@DI_TT_CAC 1
(Client Information: pid: 10824; IPC: TCP/IP;
Node: HI-LAPTOP-NGD (192.168.71.33))
Server 3460 0x0000000000e6c8a0 DI_OBIEE_AIRLINE_AGG@DI_TT_CAC 2
(Client Information: pid: 10824; IPC: TCP/IP;
Node: HI-LAPTOP-NGD (192.168.71.33))
The PID is the second column and the below parameters permits to extract it.
(Server\s*){1}([0-9]*){1}(\s*0x00.*){1}(\n.*){1}(\n.*){1}
Replace with “Return value of a bean shell”
"kill -9 "+_2
Output:
kill -9 20529
kill -9 21452
kill -9 3428
kill -9 3460
Adding a character at the end of the line
Search for:
^(.*)$
Return value of a beanshell snippet
_0+";"