IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

RegEX search in ISPF editor


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 91
Location: brisbane

PostPosted: Mon Apr 20, 2020 10:46 am
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 513
Location: Bamberg, Germany

PostPosted: Tue Apr 21, 2020 12:54 am
Reply with quote

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
View user's profile Send private message
Imabeliever

New User


Joined: 15 Aug 2019
Posts: 3
Location: Australia

PostPosted: Fri May 08, 2020 5:59 am
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 513
Location: Bamberg, Germany

PostPosted: Fri May 08, 2020 12:27 pm
Reply with quote

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:
Code:
8
abcd
efgh


So basically it works, but requires some efforts to get it right.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 513
Location: Bamberg, Germany

PostPosted: Sat May 09, 2020 11:28 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts SAY backslash within ISPF CLIST & REXX 16
This topic is locked: you cannot edit posts or make replies. How to search multiple strings in a PDS IBM Tools 3
No new posts How to search multiple members of a P... JCL & VSAM 13
No new posts Members search in PDS JCL & VSAM 9
No new posts ISPF Panel commands DDLIST /LISTBOX TSO/ISPF 11
Search our Forums:

Back to Top