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

Active User


Joined: 31 Oct 2006
Posts: 137
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

Senior Member


Joined: 15 Aug 2015
Posts: 1306
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: 4
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

Senior Member


Joined: 15 Aug 2015
Posts: 1306
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

Senior Member


Joined: 15 Aug 2015
Posts: 1306
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 Preserve changes to ISPF Panel Variables TSO/ISPF 1
No new posts can an ISPF appl save user changes in... TSO/ISPF 14
No new posts Unload and Load ISPF Table TSO/ISPF 4
No new posts ISPF Table to add a new column TSO/ISPF 1
No new posts Search two or more word with FILEAID Compuware & Other Tools 17
Search our Forums:

Back to Top