View previous topic :: View next topic
|
Author |
Message |
Gautam512
Active User
Joined: 05 Oct 2005 Posts: 308 Location: Vizag / US
|
|
|
|
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 |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
Gautam512
Active User
Joined: 05 Oct 2005 Posts: 308 Location: Vizag / US
|
|
|
|
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 |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
senman
New User
Joined: 17 Aug 2006 Posts: 17 Location: Chennai
|
|
|
|
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 |
|
|
|