Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
RegEX search in ISPF editor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> TSO/ISPF
View previous topic :: :: View next topic  
Author Message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 77
Location: brisbane

PostPosted: Mon Apr 20, 2020 10:46 am    Post subject: RegEX search in ISPF editor
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 User


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

PostPosted: Tue Apr 21, 2020 12:54 am    Post subject:
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    Post subject:
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 User


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

PostPosted: Fri May 08, 2020 12:27 pm    Post subject:
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 User


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

PostPosted: Sat May 09, 2020 11:28 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> TSO/ISPF All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ISPF Edit Macro with profile commands... Lynne Schuler TSO/ISPF 14 Thu Jun 18, 2020 7:25 pm
No new posts ISPF skeleton that has IF/THEN/DO sta... ecsk TSO/ISPF 15 Mon Apr 27, 2020 12:52 pm
No new posts How to free (unalloc) data sets and d... Ricardo Viegas TSO/ISPF 4 Wed Jan 15, 2020 5:19 am
No new posts ISPF Edit Macro for modifying JCL Cameron Conacher TSO/ISPF 21 Wed Dec 11, 2019 7:01 pm
No new posts ISPF search - capturing result jzhardy TSO/ISPF 15 Sat Dec 07, 2019 5:20 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us