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

Is there anything in ISPF where we can do a pattern matching


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gautam512

Active User


Joined: 05 Oct 2005
Posts: 308
Location: Vizag / US

PostPosted: Tue Jan 03, 2006 12:36 pm
Reply with quote

Hi all,

Is there anything in ISPF where we can do a pattern matching.

For Example :
I need to search words that start with "D" and ends with "A".

Thanks,
Gau
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Tue Jan 03, 2006 1:07 pm
Reply with quote

This is a REXX routine I wrote for pattern matching:
Code:
/****************************** REXX ******************************** */
/*                                                                    */
/* Name.......: MATCH                                                 */
/*                                                                    */
/* Function...: Pattern matching function.                            */
/*                                                                    */
/* Date.......: 07/01/2005                                            */
/*                                                                    */
/* Author.....: OFER                                                  */
/*                                                                    */
/* Reqirements: -                                                     */
/*                                                                    */
/* Description: Syntax: X = MATCH(pattern, text)                      */
/*                      pattern: Use '?' in pattern to substitute a   */
/*                      single character, and '*' to substitute any   */
/*                      number of characters.                         */
/*              Return: 0 - Mismatch                                  */
/*                      1 - match                                     */
/*                                                                    */
/**********************************************************************/
                                                                       
TEXT    = 'OFERICOOFERICO'                                             
PATTERN = 'OF?R?*L'                                                     
                                                                       
X = MATCH(PATTERN , TEXT)                                               
                                                                       
LINE    = 'Mismatch Match'                                             
SAY "Pattern '"PATTERN"'" WORD(LINE,X+1) "text '"TEXT"'"               
                                                                       
EXIT X                                                                 
                                                                       
                                                                       
MATCH: PROCEDURE                                                       
                                                                       
ARG PTR,TXT                                                             
                                                                       
PTR_LENG = LENGTH(PTR) + 1                                             
TXT_LENG = LENGTH(TXT) + 1                                             
PTR_POS  = 1                                                           
TXT_POS  = 1                                                           
                                                                       
DO WHILE PTR_POS < PTR_LENG                                             
                                                                       
  PTR_CHR = SUBSTR(PTR,PTR_POS,1)                                       
  TXT_CHR = SUBSTR(TXT,TXT_POS,1)                                       
                                                                       
  IF PTR_CHR = '*' THEN DO                                             
                                                                       
    IF PTR_POS + 1 = PTR_LENG THEN                                     
      RETURN 1                                                         
                                                                       
    PTR_NNUM = PTR_POS + 1                                             
    PTR_NEXT = SUBSTR(PTR,PTR_NNUM)                                     
    PTR_ASTR = POS('*',PTR,PTR_NNUM)                                   
                                                                       
    IF PTR_ASTR = 0 THEN                                               
      PTR_ASTR = PTR_LENG - PTR_NNUM                                   
                                                                       
    DO I = 0 TO TXT_LENG - TXT_POS - (LENGTH(PTR_NEXT) - PTR_ASTR)     
      IF MATCH(PTR_NEXT,SUBSTR(TXT,TXT_POS+I)) = 1 THEN                 
        RETURN 1                                                       
    END I                                                               
                                                                       
    RETURN 0                                                           
                                                                       
  END                                                                   
  ELSE DO                                                               
                                                                       
    IF (PTR_CHR = "?" & TXT_POS <> TXT_LENG) | PTR_CHR = TXT_CHR THEN DO
      PTR_POS = PTR_POS + 1                                             
      TXT_POS = TXT_POS + 1                                             
    END                                                                 
    ELSE                                                               
      RETURN 0                                                         
                                                                       
  END                                                                   
                                                                       
END                             
                                 
IF TXT_POS <> TXT_LENG THEN     
  RETURN 0                       
                                 
RETURN 1                         
                                 


O.
Back to top
View user's profile Send private message
Gautam512

Active User


Joined: 05 Oct 2005
Posts: 308
Location: Vizag / US

PostPosted: Tue Jan 03, 2006 1:17 pm
Reply with quote

I need a ISPF command...

Even for the Rexx code which is mentioned above we have to give the text in which the pattern is to be fetched.

If i want to fetch in a member/Program.

Thanks,
Gau
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Tue Jan 03, 2006 1:22 pm
Reply with quote

I'm sorry, but I don't understand what exactly you are trying to do. You can use this REXX (and any REXX) as a command.

Any way, there is no ISPF service/command or TSO command for pattern matching.

O.
Back to top
View user's profile Send private message
senman

New User


Joined: 17 Aug 2006
Posts: 17
Location: Chennai

PostPosted: Wed Aug 23, 2006 12:30 pm
Reply with quote

You can try using

f all ' D'
f all 'B '

when you need a word beginning with D give a space before the letter and when you need it at the end of the word give the space after the letter.

Hope this works.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Looking for a little history of ISPF ... TSO/ISPF 5
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts Issue after ISPF copy to Linklist Lib... TSO/ISPF 1
No new posts Rexx pattern matching on PS qualifer ... CLIST & REXX 1
No new posts Is there a way to close VSAM files us... CICS 8
Search our Forums:

Back to Top