Yeah, I know I can do that particular search in REXX but I'm trying to utilise regular expressions as I think that they should provide greater flexibility, if they'd only do what I want.
The concept of looking for the first string just doesn't seem to exist in the Unix world. Seems crazy to me. From: Roberto Halais <[email protected]> To: [email protected] Date: 06/02/2012 15:04 Subject: Re: Regular Expressions (OMVS) Sent by: IBM Mainframe Discussion List <[email protected]> I don't know if this is what you want: /* REXX */ EXP = "QQQQABCDEFGNOPQRXXXPPPPABCDEFGNOPQRYYYOOOOABCDEFGNOPQRZZZ" START = POS("QR",EXP) SAY START EXIT 0 Result is 15 On Mon, Feb 6, 2012 at 10:44 AM, Ken MacKenzie <[email protected]> wrote: > Hi All, > > I'm not sure if this is the appropriate forum, please point me to the correct one if it's not. > > I'm playing around with regular expressions and I want to achieve the following. I spoke to a Unix geek but he didn't really understand what I was asking. > > Given the following sample data, I want discover only the first occurrence of any string which matches my regexp. > QQQQABCDEFGNOPQRXXXPPPPABCDEFGNOPQRYYYOOOOABCDEFGNOPQRZZZ > QQQQABCDEFGNOPQRXXXPPPPABCDEFGNOPQRYYYOOOOABCDEFGNOPQRZZZ > QQQQABCDEFGNOPQRXXXPPPPABCDEFGNOPQRYYYOOOOABCDEFGNOPQRZZZ > QQQQABCDEFGNOPQRXXXPPPPABCDEFGNOPQRYYYOOOOABCDEFGNOPQRZZZ > QQQQABCDEFGNOPQRXXXPPPPABCDEFGNOPQRYYYOOOOABCDEFGNOPQRZZZ > QQQQABCDEFGNOPQRXXXPPPPABCDEFGNOPQRYYYOOOOABCDEFGNOPQRZZZ > > I tried: awk 'sub(/CD.*QR/,"junkt")' fxdata in an attempt to change QQQQABCDEFGNOPQRXXX to QQQQABjunktXXX but instead, it takes the final occurrence of QR, and returns QQQQABjunktZZZ. Notice the ZZZ on the end instead of XXX. > > This is being driven from a REXX exec in ISPF, if any of the above is not clear, I will try to explain further. > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN -- "Those who can make you believe religious absurdities, can make you commit atrocities." Voltaire The philosopher has never killed any priests, whereas the priest has killed a great many philosophers. Denis Diderot "Men will never be free until the last king is strangled with the entrails of the last priest." Denis Diderot ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN

