View previous topic :: View next topic
|
Author |
Message |
Deepak Dash
New User
Joined: 03 Sep 2007 Posts: 16 Location: India
|
|
|
|
Hi All,
I have below requirements and I appriciate if someone can help me.
I have a address Line of 30 Bytes lenght i.e. let's say Address PIC X(30).
I need to search this Address string for a particular string "CONFIDENTIAL" or "confidential" (Both Capital o small case letter may exist). If I found a hit then i will follow another logic.
Second requirment -
In the same string of X(30), I need to search for a particular date patteren like '%_/_/_%' or '%_-_-_%'.
Can anybody guide me if it's possible to do this Logic using COBOL?
Thanks for help. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Using an inspect for the string, and an array (or more than 1), or reference modification, you can accomplish the pattern match within a couple of loops.
You need to determine which patterns are valid and then alllow for all valid patterns in the code. Until you have well established the "rules" coding would be premature. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
I think INSPECT finds occurrences of 'confidential' regardless of case. Test it and let us know. |
|
Back to top |
|
|
Deepak Dash
New User
Joined: 03 Sep 2007 Posts: 16 Location: India
|
|
|
|
Hi Terry,
Thanks. INSPECT does work and also gives me the count. Can you please let me know how do I find the date patteren in my string?
like '%_/_/_%' or '%_-_-_%'.
Thanks |
|
Back to top |
|
|
gkpabbati
New User
Joined: 25 May 2005 Posts: 3 Location: Hyderabad
|
|
|
|
similarly you can do 'INSPECT' for '/ 'or '-' , 3rd and 6th byte using reference modification |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
INSPECT won't be much help for doing the pattern match. It might be used to find the first position, but i'd not try to say until the rules have all been shown.
The code will need to parse across the data until a potential beginning-of-pattern is found. Will the pattern always start and end with %? Could there be more than one pattern in the data? What is to happen when a pattern is found? Are single-digit month and day valid? |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Dick, I think Deepak is using % as a wildcard character, not literally a percent sign. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Terry,
Very possibly. . . Maybe something more useful will follow. . .
d |
|
Back to top |
|
|
|