View previous topic :: View next topic
|
Author |
Message |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 137 Location: brisbane
|
|
|
|
hi all,
i've found the regex option in the ISPF editor to be extremely useful.
However, I have not been able to work out a way to get the search to span across multiple (logical) lines.
eg, I would like : F R"abc.*\nefg" to match:
abcd
efgh
obviously \n is meaningless with logical records. But the question remains - is there a way to make regex sensitive to logical records and able to match across them ? |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1306 Location: Bamberg, Germany
|
|
|
|
ISPF uses the IBM C regcomp and regexec functions to compile and execute a regular expression specified with a FIND, CHANGE, or EXCLUDE command.
As it supports only an absolute minimum of RE, I don't think it can be used to search multilines.
On a side note, when using Case Sensitive expressions you should use f rc'<expression>' |
|
Back to top |
|
|
Imabeliever
New User
Joined: 15 Aug 2019 Posts: 4 Location: Australia
|
|
|
|
If you can be bothered, you could copy the data to a file in USS and search it there, although that is not strictly an ISPF solution. Are you confined to ISPF alone? |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1306 Location: Bamberg, Germany
|
|
|
|
No need to copy the dataset to USS first.
For the given sample data of a two line match:
Code: |
****** ******************
000001 garbage
000002 garbage
000003 garbage
000004 garbage
000005 garbage
000006 garbage everywhere
000007 abcd
000008 efgh
000009 more garbage
000010 The End
****** ****************** |
Switch to USS and issue:
Code: |
cat "//'<dataset>'" | sed -n '/^abcd[ ]*$/{N;/^abcd[ ]*.\+efgh[ ]*$/;=;p;}' |
Output:
So basically it works, but requires some efforts to get it right. |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1306 Location: Bamberg, Germany
|
|
|
|
A minor update necessary for the following constellation:
Code: |
******************
abcd
abcd
efgh
garbage
garbage
garbage
garbage
garbage
garbage everywhere
abcd
efgh
efgh
more garbage
The End
abcd
3456
****************** |
Should list lines 2/3 and 10/11
Code: |
3
abcd
efgh
11
abcd
efgh |
Command used:
Code: |
cat "//'<dataset>'" | sed -n '/abcd/{N;/abcd\nefgh/!D;=;p;}' |
|
|
Back to top |
|
|
|