View previous topic :: View next topic
|
Author |
Message |
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
Hi
How to make a wildcard search in REXX?
If I want to do a wild card search in a string like the following, how do to do it REXX?
I'm sure of only First, Second and 7th Character.
I want to figure all the variables like
Code: |
'AB1234B5'
'AB4567B3'
'ABSDTTB2'
'AB34VBB7' |
the above may be a part of the string like
Code: |
'The data is sensitive, AB1234B5 the code' |
I wanna find whether anything like 'AB****B*' is present. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
AFAIK there is no built in functions for a wildcard - so it looks as if you need to code and test your own logic here. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
If you are trying to acheive it in rexx code
Try some thing like
Code: |
SUBSTR(STEM VARIABLE,1,2) = AB and
SUBSTR(STEM VARIABLE,7,1) = B
|
Just gave a thought having assumtions.
Experts guide me |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Code: |
STRING.0 = 4
STRING.1 = 'ABCDEFGHIJKLMB'
STRIN0.2 = 'AB345B789'
STRING.3 = '13456789'
STRING.4 = '1234567890AB3456B789'
KEY_POS_1_2 = 'AB'
KEY_POS_7 = 'B'
TRACE ?R
DO I = 1 TO STRING.0
X = POS(KEY_POS_1_2,STRING.I)
IF X > 0 THEN
DO
Y = POS(KEY_POS_7,STRING.I,X+2)
IF Y > 0 THEN
DO
IF Y - X = 6 THEN
DO
SAY 'HIT IN ' STRING.I
END
END
END
END
EXIT
|
not elegant, but beggers can't be choosers;
they must create their own 'elegant' code. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Much better [] Thanks dick
but beggers can't be choosers;
wht did you mean by that mind eloborating?
Thanks |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
It's a slang term meaning roughly that when you receive something for free, you don't have much of a right to complain about what you get. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Take a look at file 656 in CBTTAPE.
O. |
|
Back to top |
|
|
cmsmoon
New User
Joined: 17 Jun 2010 Posts: 75 Location: Chennai
|
|
|
|
you can use the commands to search string
F ALL P'C==PO'
= -> wildcard charater |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The discussion ended nearly four years ago.
Having said that, do you feel that you actually read the question? |
|
Back to top |
|
|
cmsmoon
New User
Joined: 17 Jun 2010 Posts: 75 Location: Chennai
|
|
|
|
All discussion not ended Acutally.Let have a new Idea for wildcard search!!! |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Bill,
That is why Friday is Psychic |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
cmsmoon wrote: |
All discussion not ended Acutally.Let have a new Idea for wildcard search!!! |
A good pre-condition would be having an idea that works. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
you can use the commands to search string
F ALL P'C==PO'
= -> wildcard charater |
Where did you find documentation that says the "=" can be used as a wildcard?
Please do not post an untested/unworking "solution".
Also, when a topic has been dormant for so long, it is best to start a new topic and include the link to the old one if you feel it is necessary/useful. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
dick scherrer wrote: |
Hello,
Quote: |
you can use the commands to search string
F ALL P'C==PO'
= -> wildcard charater |
Where did you find documentation that says the "=" can be used as a wildcard? |
cmsmoon is confusing (to put it politely) Rexx with ISPF Edit; the equals sign is a generic wildcard in picture strings. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2596 Location: Silicon Valley
|
|
|
|
Quote: |
confusing (to put it politely) Rexx with ISPF Edit |
That is a great idea, Akatsukami: put the text in a file and then edit it with an initial macro that issues the FIND command. VPUT the return code of the FIND so that it can be found later by the caller.
But it is not very practical for a large amount of data to search through. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2147 Location: USA
|
|
|
|
/* REXX - verify wildcard without going into loop */
WildCard = 'ABC**1**Z'
String = 'We want to find something like ABC001xxZ but not ABC002xxY'
HiMask = Translate( WildCard, 'FF'x, '*' )
LowMask = Translate( WildCard, '00'x, '*' )
Do i = 1 to Words(String)
Single = Word( String, i )
HiSingle = BitAnd( Single, HiMask )
LowSingle = BitOr( Single, LowMask )
If HiSingle == LowSingle Then
Say "Word" Single "found - success!"
End i
return 0 |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
sergeyken, did you notice that you are responding to a topic with the last post 3 years ago and originally started 7 years ago? |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2147 Location: USA
|
|
|
|
Robert Sample wrote: |
sergeyken, did you notice that you are responding to a topic with the last post 3 years ago and originally started 7 years ago? |
Nevertheless the issue is as important as before. |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
sergeyken wrote: |
Robert Sample wrote: |
sergeyken, did you notice that you are responding to a topic with the last post 3 years ago and originally started 7 years ago? |
Nevertheless the issue is as important as before. |
It's a practice Not to answer a question Years after it was asked because:
1. The OP will not be interested in listening after Years of asking the question.
2. More importantly, the technology would/may have changed in those Years. So, the question itself would/may not be valid.
*Think about how you used to travel with Paper maps 10 Years ago. And now you have GPS. The question asked for a paper map would not be valid today And that is why It is Not a good practice to reply to Years old threads.
. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Quote: |
Nevertheless the issue is as important as before. |
Along with what RahuldG31 said, You can always start a new post with the tested solution and link this old thread to it instead of waking up the dead thread which would be useful for others. May be this needs to get a lock now. |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Every time an old thread is wakened we go through this.
It is like ibmmainframes 'groundhog day'.
The 'prince charming' who wakes the sleeping beauty really has no idea they have done anything wrong.
Why is a new thread linking to an old one any better than a new entry in the old thread?
Is there anyway to have the site lock a thread after six months (or a year) of in-activity?
This would take care of all concerns.
Just my opinion on the matter. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Topic locked to avoid any further resurrections |
|
Back to top |
|
|
|