Re: regex always returns 1
Eric,, Ok, that works, but its not what I expected from reading the docs. The docs for REG_NOSUB parameter to regcomp. REG_NOSUB Report only success or fail in regexec(), that is, verify the syntax of a regular expression. If this flag is set, the regcomp() function sets re_nsub to the number of parenthesized sub-expressions found in pattern. Otherwise, a sub-expression results in an error. Along with this statement for regexec If nmatch parameter is 0 or REG_NOSUB was set on the call to regcomp(), regexec() ignores the pmatch argument. Otherwise, the pmatch argument points to an array of at least nmatch elements. I thought that regexec would just return success/failure on the search. Apparently, I totally misunderstood the documentation, which is not uncommon :-> Thanks a bunch Eric Erickson -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex always returns 1
You used REG_NOSUB on the regcomp, which just verifies the syntax. You want REG_EXTENDED since you have an extended regex. Eric Rossman -Original Message- From: IBM Mainframe Discussion List On Behalf Of Seymour J Metz Sent: Friday, June 30, 2023 11:17 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: [EXTERNAL] Re: regex always returns 1 I don't understand. A ^ at the beginning of a character class is a Not. The regex should match a string of invalid characters, or fail if there are none. From: IBM Mainframe Discussion List on behalf of Eric Erickson Sent: Friday, June 30, 2023 10:56 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: regex always returns 1 I'm having an issue with trying to use a regular expression to validate an z/OS Dataset Name Qualifier. I traverse the DSN using strtok to extract a pointer to each qualifier. I built a regular expression that works using a web tool to identify any invalid characters. The string I build using the web tool is "[^A-Z0-9@#\$\}\-]+" which when I bring that up the mainframe I change to "[^A-Z0-9@#\\$\\}\\-]+" as I have to double the escape (\) otherwise the compiler issues a message. Even when I shorted the regex to ""[^A-Z0-9]+" is returns a 1 for both strings (SCHEMA or SCH!MA) where I would expect the first to return 1 and second to return 0. Basically I'm trying to validate that a string does not contain any lower case characters or any of the symbols except ($, @, #, -, or }). Here is a subset of the code. if (regcomp(, pszDsnPattern, REG_NOSUB) == 0) { printf("ZDP2999T: RegEx compiled %s.\n", pszDsnPattern); /* ** Regular Expression compiled, make a copy of the buffer, as strtok ** is going to destroy it during tokenization. */ strcpy(cBuffer, pszKeyValue); /* ** Get the first token in the string. */ pszToken = strtok(cBuffer, "."); /* ** And loop through the string processing each returned string. */ do { /* ** Perform z/OS Dataset Name Validation. Check the qualifier length ** and first character for validity. */ printf("ZDP2999T: Qualifier \"%s\".\n", pszToken); if (strlen(pszToken) <= 8 & (isupper(pszToken[0]) || pszToken[0] == '$' || pszToken[0] == '@' || pszToken[0] == '#')) { printf("ZDP2999T: Valid first char %c.\n", pszToken[0]); if ((iRc = regexec(, pszToken, 0, NULL, 0)) == 0) { bValidDbHlq = FALSE; } } else{ bValidDbHlq = FALSE; } } while ((pszToken = strtok(NULL, ".")) & bValidDbHlq); /* ** Free the regex allocated storage. */ regfree(); Note: I do handle the special case of the first character via a separate test, but don't want to iterate through the remaining characters in a loop. This is all under XL C under z/OS 2.5. -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex always returns 1
I don't understand. A ^ at the beginning of a character class is a Not. The regex should match a string of invalid characters, or fail if there are none. From: IBM Mainframe Discussion List on behalf of Eric Erickson Sent: Friday, June 30, 2023 10:56 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: regex always returns 1 I'm having an issue with trying to use a regular expression to validate an z/OS Dataset Name Qualifier. I traverse the DSN using strtok to extract a pointer to each qualifier. I built a regular expression that works using a web tool to identify any invalid characters. The string I build using the web tool is "[^A-Z0-9@#\$\}\-]+" which when I bring that up the mainframe I change to "[^A-Z0-9@#\\$\\}\\-]+" as I have to double the escape (\) otherwise the compiler issues a message. Even when I shorted the regex to ""[^A-Z0-9]+" is returns a 1 for both strings (SCHEMA or SCH!MA) where I would expect the first to return 1 and second to return 0. Basically I'm trying to validate that a string does not contain any lower case characters or any of the symbols except ($, @, #, -, or }). Here is a subset of the code. if (regcomp(, pszDsnPattern, REG_NOSUB) == 0) { printf("ZDP2999T: RegEx compiled %s.\n", pszDsnPattern); /* ** Regular Expression compiled, make a copy of the buffer, as strtok ** is going to destroy it during tokenization. */ strcpy(cBuffer, pszKeyValue); /* ** Get the first token in the string. */ pszToken = strtok(cBuffer, "."); /* ** And loop through the string processing each returned string. */ do { /* ** Perform z/OS Dataset Name Validation. Check the qualifier length ** and first character for validity. */ printf("ZDP2999T: Qualifier \"%s\".\n", pszToken); if (strlen(pszToken) <= 8 & (isupper(pszToken[0]) || pszToken[0] == '$' || pszToken[0] == '@' || pszToken[0] == '#')) { printf("ZDP2999T: Valid first char %c.\n", pszToken[0]); if ((iRc = regexec(, pszToken, 0, NULL, 0)) == 0) { bValidDbHlq = FALSE; } } else{ bValidDbHlq = FALSE; } } while ((pszToken = strtok(NULL, ".")) & bValidDbHlq); /* ** Free the regex allocated storage. */ regfree(); Note: I do handle the special case of the first character via a separate test, but don't want to iterate through the remaining characters in a loop. This is all under XL C under z/OS 2.5. -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Regex (was: Sort for not there?)
On Fri, 8 Jan 2016, at 16:25, Paul Gilmartin wrote: > And, in the "CHANGE string1 string2" command, how can I specify > a string2 containing an arbitrary mixture of quotation marks, > apostrophes, and spaces? c x'xxx' x'yyy' It's useful to do that in edit macros etc where one has no idea what the parms will be. It's also a useful way of passing arbitray arguments between programs via a commandline. -- Jeremy Nicoll - my opinions are my own. -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Regex (was: Sort for not there?)
On Sat, 9 Jan 2016 12:08:25 +, Jeremy Nicoll wrote: > >> And, in the "CHANGE string1 string2" command, how can I specify >> a string2 containing an arbitrary mixture of quotation marks, >> apostrophes, and spaces? > >c x'xxx' x'yyy' > PITA, unless it's driven by a macro. And can the 'xxx' be made case-sensitive or -insensitive at the programmer's discretion? >It's useful to do that in edit macros etc where one has no idea what the parms >will be. It's also a useful way of passing arbitray arguments between >programs >via a commandline. > Again, practical only from a macro, not from a terminal command line. And it depends on the target program's being able to interpret the hex. For example, I know no way to put hex values in a regular expression. I had a case where I wanted to pass the ISPF startup command a string containing unmatched apostrophes, or parentheses (I forget). I found no way and gave up. -- gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Regex (was: Sort for not there?)
On Fri, 8 Jan 2016 10:25:05 -0600, Paul Gilmartin wrote: >On Thu, 7 Jan 2016 18:07:11 -0700, Alan Young wrote: >> >>The spaces also need the escape backslash like this >> >>FIND r'foo\ \'\ bar\ \"\ wombat' >> >This is bizarre. I've coded a fair amount of regular expressions and >I've never needed to escape a blank in a regular expression. In fact, >Single UNIX says: > >The interpretation of an ordinary character preceded by a > ( '\\' ) is undefined, > >The z/OS XL C/C++ Runtime Library Reference in the description of >regcmp(), which is described as "withdrawn and are not supported as >part of Single UNIX Specification ..." states: > >Note: An non-special character preceded by \ is a one-character >RE which matches the non-special character. > >The description of the newer regcomp() makes no such statement. > >Is backslash escaping elaborated by ISPF EDIT or by regcomp()? > >I have an RCF in requesting a clarification of ISPF's syntax of >delimited strings. My case in point is that with the subject: > >My aunt's pen isn't on the table. > >The command: > >FIND 'aunt's pen' > >matches successfully, but the very similar: > >FIND 'isn't on' > >fails with a syntax error. I can find no explanation of the >difference in current ISPF manuals. I suspect a historical >explanation. In this case, the parser considers this: 'isn't the equivalent of this: t'isn' and stops there, and anything after that is expected to be something like NEXT, PREV, FIRST, LAST, or ALL. If there was some character other than t, c, p, r, or x after the quote, it would work. If there was some character other than a space after the 't it would work. Not defending it, just explaining what's going on. Bill -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Regex (was: Sort for not there?)
That works as expected, it does not interpret the "t'" as a TEXT find. I did test it. Al Nims Systems Admin/Programmer 3 UFIT University of Florida (352) 273-1298 -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Skip Robinson Sent: Friday, January 08, 2016 5:11 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Regex (was: Sort for not there?) This explanation makes perfect sense. ISPF was written to allow utter maximum flexibility in command coding. Of course the t appears to stand for 'text'. I can't try this out now, but I wonder if using " instead of ' for the entire string would give the desired result. FIND "isn't on" That's how I would code it on principle anyway. . . . J.O.Skip Robinson Southern California Edison Company Electric Dragon Team Paddler SHARE MVS Program Co-Manager 323-715-0595 Mobile jo.skip.robin...@att.net jo.skip.robin...@gmail.com > -Original Message- > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] > On Behalf Of Bill Godfrey > Sent: Friday, January 8, 2016 10:59 AM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: [Bulk] Re: Regex (was: Sort for not there?) > > On Fri, 8 Jan 2016 10:25:05 -0600, Paul Gilmartin wrote: > > >On Thu, 7 Jan 2016 18:07:11 -0700, Alan Young wrote: > >> > >>The spaces also need the escape backslash like this > >> > >>FIND r'foo\ \'\ bar\ \"\ wombat' > >> > >This is bizarre. I've coded a fair amount of regular expressions and > >I've never needed to escape a blank in a regular expression. In > >fact, Single UNIX says: > > > >The interpretation of an ordinary character preceded by a > > ( '\\' ) is undefined, > > > >The z/OS XL C/C++ Runtime Library Reference in the description of > >regcmp(), which is described as "withdrawn and are not supported as > >part of Single UNIX Specification ..." states: > > > >Note: An non-special character preceded by \ is a one-character > >RE which matches the non-special character. > > > >The description of the newer regcomp() makes no such statement. > > > >Is backslash escaping elaborated by ISPF EDIT or by regcomp()? > > > >I have an RCF in requesting a clarification of ISPF's syntax of > >delimited strings. My case in point is that with the subject: > > > >My aunt's pen isn't on the table. > > > >The command: > > > >FIND 'aunt's pen' > > > >matches successfully, but the very similar: > > > >FIND 'isn't on' > > > >fails with a syntax error. I can find no explanation of the > >difference in current ISPF manuals. I suspect a historical explanation. > > In this case, the parser considers this: > 'isn't > the equivalent of this: > t'isn' > and stops there, and anything after that is expected to be something > like NEXT, PREV, FIRST, LAST, or ALL. > > If there was some character other than t, c, p, r, or x after the > quote, it would work. > > If there was some character other than a space after the 't it would work. > > Not defending it, just explaining what's going on. > > Bill -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Regex (was: Sort for not there?)
This explanation makes perfect sense. ISPF was written to allow utter maximum flexibility in command coding. Of course the t appears to stand for 'text'. I can't try this out now, but I wonder if using " instead of ' for the entire string would give the desired result. FIND "isn't on" That's how I would code it on principle anyway. . . . J.O.Skip Robinson Southern California Edison Company Electric Dragon Team Paddler SHARE MVS Program Co-Manager 323-715-0595 Mobile jo.skip.robin...@att.net jo.skip.robin...@gmail.com > -Original Message- > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] > On Behalf Of Bill Godfrey > Sent: Friday, January 8, 2016 10:59 AM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: [Bulk] Re: Regex (was: Sort for not there?) > > On Fri, 8 Jan 2016 10:25:05 -0600, Paul Gilmartin wrote: > > >On Thu, 7 Jan 2016 18:07:11 -0700, Alan Young wrote: > >> > >>The spaces also need the escape backslash like this > >> > >>FIND r'foo\ \'\ bar\ \"\ wombat' > >> > >This is bizarre. I've coded a fair amount of regular expressions and > >I've never needed to escape a blank in a regular expression. In fact, > >Single UNIX says: > > > >The interpretation of an ordinary character preceded by a > > ( '\\' ) is undefined, > > > >The z/OS XL C/C++ Runtime Library Reference in the description of > >regcmp(), which is described as "withdrawn and are not supported as > >part of Single UNIX Specification ..." states: > > > >Note: An non-special character preceded by \ is a one-character > >RE which matches the non-special character. > > > >The description of the newer regcomp() makes no such statement. > > > >Is backslash escaping elaborated by ISPF EDIT or by regcomp()? > > > >I have an RCF in requesting a clarification of ISPF's syntax of > >delimited strings. My case in point is that with the subject: > > > >My aunt's pen isn't on the table. > > > >The command: > > > >FIND 'aunt's pen' > > > >matches successfully, but the very similar: > > > >FIND 'isn't on' > > > >fails with a syntax error. I can find no explanation of the difference > >in current ISPF manuals. I suspect a historical explanation. > > In this case, the parser considers this: > 'isn't > the equivalent of this: > t'isn' > and stops there, and anything after that is expected to be something like > NEXT, > PREV, FIRST, LAST, or ALL. > > If there was some character other than t, c, p, r, or x after the quote, it > would > work. > > If there was some character other than a space after the 't it would work. > > Not defending it, just explaining what's going on. > > Bill -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: Regex (was: ... Unix file system ...)
On Mon, 29 Jul 2013 10:50:30 -0500, Paul Gilmartin wrote: And I wonder further, if I have autoconversion enabled, and I'm processing an ASCII (tagged) file with sed or awk and my purportedly portable script has \nnn octal escape sequences to match nondisplayable code points, will those match ASCII code points or EBCDIC code points? I'm pessimistic. ISPF has pleasantly surprised me. When I OEDIT a file tagged ASCII and set HEX ON, I see ASCII code points. When I do FIND X'...', it finds the string according to the ASCII code points. I had feared it would perform the translation between the file and the edit buffer. The doc makes it clear that the translation is performed between ISPF and the 3270, but such things always bear testing. -- gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
Welsh orthography does not figure largely in American 'grammar'---for which read 'primary'---school curricula. A more apposite, albeit trite, example is provided by QANTAS, the name of the Australian flag airline. It was originally an acronym for 'Queensland And Northern Territories Aerial Services [Limited]', but it became a stand-alone name almost immediately. Some token usages overlap. 'Qom' is the name of a Persian city [and province], a Shia pilgrimage center since the 17th century. In the variant form QOM is is also an acronym for, among a good many other things, 'Quick Ontological Mapping'. The substantial point here is that glittering universal formulations---as in Thou shalt not commit a GOTO!--- are always wrong, in programming and elsewhere. John Gilmore, Ashland, MA 01721 - USA -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
Shmuel Just for your information, the Welsh language does not have a 'q' in it. Nor does it have 'j', 'k', 'v', 'x' or 'z'. But, we do have many more 'letters' which are combinations of letters, such examples being 'ch', 'dd', 'ff', 'll', 'ng, and 'ph'. ALH -Original Message- From: Shmuel Metz (Seymour J.) shmuel+...@patriot.net To: IBM-MAIN IBM-MAIN@LISTSERV.UA.EDU Sent: Thu, 11 Jul 2013 2:28 Subject: Re: regex that never matches? In 0382727397514044.wa.paulgboulderaim@listserv.ua.edu, on 07/10/2013 at 10:47 AM, Paul Gilmartin paulgboul...@aim.com said: I was taught in grammar school that q occurs only followed by u. Before the ascendancy of Middle Eastern politics. Welsh? -- Shmuel (Seymour J.) Metz, SysProg and JOAT Atid/2http://patriot.net/~shmuel We don't care. We don't have to care, we're Congress. (S877: The Shut up and Eat Your spam act of 2003) -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
I am delighted that a Welsh speaker has put Shmuel straight about the letter 'q'. I considered trying to do so, but decided that any such attempt would implicitly misrepresent my knowledge of Welsh as much more substantial than it is. John Gilmore, Ashland, MA 01721 - USA -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
Welsh as an early example of the DBCS or Double Byte character Set? Mike Wawiorko Please consider the environment before printing this e-mail -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Aled Hughes Sent: 11 July 2013 13:56 To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: regex that never matches? Shmuel Just for your information, the Welsh language does not have a 'q' in it. Nor does it have 'j', 'k', 'v', 'x' or 'z'. But, we do have many more 'letters' which are combinations of letters, such examples being 'ch', 'dd', 'ff', 'll', 'ng, and 'ph'. ALH This e-mail and any attachments are confidential and intended solely for the addressee and may also be privileged or exempt from disclosure under applicable law. If you are not the addressee, or have received this e-mail in error, please notify the sender immediately, delete it from your system and do not copy, disclose or otherwise act upon any part of this e-mail or its attachments. Internet communications are not guaranteed to be secure or virus-free. The Barclays Group does not accept responsibility for any loss arising from unauthorised access to, or interference with, any Internet communications by any third party, or from the transmission of any viruses. Replies to this e-mail may be monitored by the Barclays Group for operational or business reasons. Any opinion or other information in this e-mail or its attachments that does not relate to the business of the Barclays Group is personal to the sender and is not given or endorsed by the Barclays Group. Barclays Bank PLC. Registered in England and Wales (registered no. 1026167). Registered Office: 1 Churchill Place, London, E14 5HP, United Kingdom. Barclays Bank PLC is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority (Financial Services Register No. 122702). -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
With so many 2 character letters, you have an unfair advantage in the competition for the village with the longest name in the world. Kees. -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Aled Hughes Sent: Thursday, July 11, 2013 14:56 To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: regex that never matches? Shmuel Just for your information, the Welsh language does not have a 'q' in it. Nor does it have 'j', 'k', 'v', 'x' or 'z'. But, we do have many more 'letters' which are combinations of letters, such examples being 'ch', 'dd', 'ff', 'll', 'ng, and 'ph'. ALH -Original Message- From: Shmuel Metz (Seymour J.) shmuel+...@patriot.net To: IBM-MAIN IBM-MAIN@LISTSERV.UA.EDU Sent: Thu, 11 Jul 2013 2:28 Subject: Re: regex that never matches? In 0382727397514044.wa.paulgboulderaim@listserv.ua.edu, on 07/10/2013 at 10:47 AM, Paul Gilmartin paulgboul...@aim.com said: I was taught in grammar school that q occurs only followed by u. Before the ascendancy of Middle Eastern politics. Welsh? -- Shmuel (Seymour J.) Metz, SysProg and JOAT Atid/2http://patriot.net/~shmuel We don't care. We don't have to care, we're Congress. (S877: The Shut up and Eat Your spam act of 2003) -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN For information, services and offers, please visit our web site: http://www.klm.com. This e-mail and any attachment may contain confidential and privileged material intended for the addressee only. If you are not the addressee, you are notified that no part of the e-mail or any attachment may be disclosed, copied or distributed, and that any other action related to this e-mail or attachment is strictly prohibited, and may be unlawful. If you have received this e-mail by error, please notify the sender immediately by return e-mail, and delete this message. Koninklijke Luchtvaart Maatschappij NV (KLM), its subsidiaries and/or its employees shall not be liable for the incorrect or incomplete transmission of this e-mail or any attachments, nor responsible for any delay in receipt. Koninklijke Luchtvaart Maatschappij N.V. (also known as KLM Royal Dutch Airlines) is registered in Amstelveen, The Netherlands, with registered number 33014286 -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
With so many 2 character letters, you have an unfair advantage in the competition for the village with the longest name in the world. You must mean: Llanfairpwllgwyngyllgogerychwyrndrobwantysiliogogogoch Written purely from memory so please forgive any mistakes! Dave Salt SimpList(tm) - try it; you'll get it! http://www.mackinney.com/products/program-development/simplist.html Date: Thu, 11 Jul 2013 15:19:39 +0200 From: kees.verno...@klm.com Subject: Re: regex that never matches? To: IBM-MAIN@LISTSERV.UA.EDU With so many 2 character letters, you have an unfair advantage in the competition for the village with the longest name in the world. Kees. -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Aled Hughes Sent: Thursday, July 11, 2013 14:56 To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: regex that never matches? Shmuel Just for your information, the Welsh language does not have a 'q' in it. Nor does it have 'j', 'k', 'v', 'x' or 'z'. But, we do have many more 'letters' which are combinations of letters, such examples being 'ch', 'dd', 'ff', 'll', 'ng, and 'ph'. ALH -Original Message- From: Shmuel Metz (Seymour J.) shmuel+...@patriot.net To: IBM-MAIN IBM-MAIN@LISTSERV.UA.EDU Sent: Thu, 11 Jul 2013 2:28 Subject: Re: regex that never matches? In 0382727397514044.wa.paulgboulderaim@listserv.ua.edu, on 07/10/2013 at 10:47 AM, Paul Gilmartin paulgboul...@aim.com said: I was taught in grammar school that q occurs only followed by u. Before the ascendancy of Middle Eastern politics. Welsh? -- Shmuel (Seymour J.) Metz, SysProg and JOAT Atid/2http://patriot.net/~shmuel We don't care. We don't have to care, we're Congress. (S877: The Shut up and Eat Your spam act of 2003) -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN For information, services and offers, please visit our web site: http://www.klm.com. This e-mail and any attachment may contain confidential and privileged material intended for the addressee only. If you are not the addressee, you are notified that no part of the e-mail or any attachment may be disclosed, copied or distributed, and that any other action related to this e-mail or attachment is strictly prohibited, and may be unlawful. If you have received this e-mail by error, please notify the sender immediately by return e-mail, and delete this message. Koninklijke Luchtvaart Maatschappij NV (KLM), its subsidiaries and/or its employees shall not be liable for the incorrect or incomplete transmission of this e-mail or any attachments, nor responsible for any delay in receipt. Koninklijke Luchtvaart Maatschappij N.V. (also known as KLM Royal Dutch Airlines) is registered in Amstelveen, The Netherlands, with registered number 33014286 -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
Welsh is a better example of an MBCS precursor, as in Ralph == 'raf', but single phonemes represented as digraphs and trigraphs are common in many languages. John Gilmore, Ashland, MA 01721 - USA -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
In 9391203323671928.wa.paulgboulderaim@listserv.ua.edu, on 07/09/2013 at 09:56 AM, Paul Gilmartin paulgboul...@aim.com said: Thanks! I never woulda thoughta that. Seems to work for sed and grep; nearly an exhaustive sample. Now I need to try to understand it: The sequence (? starts an extended pattern; in this case, a look-around assertion (?!pattern) with a null pattern. 'A zero-width negative look-ahead assertion. For example /foo(?!bar)/ matches any occurrence of foo that isn't followed by bar.' -- Shmuel (Seymour J.) Metz, SysProg and JOAT Atid/2http://patriot.net/~shmuel We don't care. We don't have to care, we're Congress. (S877: The Shut up and Eat Your spam act of 2003) -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
This reminds me of an experiment of a colleague of mine, several years ago. He tried to transform a Rexx program of about one screen of statements into one Rexx statement, using nesting, recursive programming and other fancy stuff. It took him about a week, but he succeeded. Of course it was completely incomprehensible what the statement did, but it worked. Kees. -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Shmuel Metz (Seymour J.) Sent: Wednesday, July 10, 2013 03:17 To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: regex that never matches? In 9391203323671928.wa.paulgboulderaim@listserv.ua.edu, on 07/09/2013 at 09:56 AM, Paul Gilmartin paulgboul...@aim.com said: Thanks! I never woulda thoughta that. Seems to work for sed and grep; nearly an exhaustive sample. Now I need to try to understand it: The sequence (? starts an extended pattern; in this case, a look-around assertion (?!pattern) with a null pattern. 'A zero-width negative look-ahead assertion. For example /foo(?!bar)/ matches any occurrence of foo that isn't followed by bar.' -- Shmuel (Seymour J.) Metz, SysProg and JOAT Atid/2http://patriot.net/~shmuel We don't care. We don't have to care, we're Congress. (S877: The Shut up and Eat Your spam act of 2003) -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN For information, services and offers, please visit our web site: http://www.klm.com. This e-mail and any attachment may contain confidential and privileged material intended for the addressee only. If you are not the addressee, you are notified that no part of the e-mail or any attachment may be disclosed, copied or distributed, and that any other action related to this e-mail or attachment is strictly prohibited, and may be unlawful. If you have received this e-mail by error, please notify the sender immediately by return e-mail, and delete this message. Koninklijke Luchtvaart Maatschappij NV (KLM), its subsidiaries and/or its employees shall not be liable for the incorrect or incomplete transmission of this e-mail or any attachments, nor responsible for any delay in receipt. Koninklijke Luchtvaart Maatschappij N.V. (also known as KLM Royal Dutch Airlines) is registered in Amstelveen, The Netherlands, with registered number 33014286 -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
In 2304481172006741.wa.paulgboulderaim@listserv.ua.edu, on 07/09/2013 at 02:31 AM, Paul Gilmartin paulgboul...@aim.com said: But is there a general case: a regex that will never match any string whatever? Well, (*FAIL) is experimental, but what about (?!)? -- Shmuel (Seymour J.) Metz, SysProg and JOAT Atid/2http://patriot.net/~shmuel We don't care. We don't have to care, we're Congress. (S877: The Shut up and Eat Your spam act of 2003) -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
Ex APL programmer? snip This reminds me of an experiment of a colleague of mine, several years ago. He tried to transform a Rexx program of about one screen of statements into one Rexx statement, using nesting, recursive programming and other fancy stuff. It took him about a week, but he succeeded. Of course it was completely incomprehensible what the statement did, but it worked. Kees. /snip -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
No idea, he is not working here anymore. Kees. -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Staller, Allan Sent: Wednesday, July 10, 2013 14:56 To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: regex that never matches? Ex APL programmer? snip This reminds me of an experiment of a colleague of mine, several years ago. He tried to transform a Rexx program of about one screen of statements into one Rexx statement, using nesting, recursive programming and other fancy stuff. It took him about a week, but he succeeded. Of course it was completely incomprehensible what the statement did, but it worked. Kees. /snip -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN For information, services and offers, please visit our web site: http://www.klm.com. This e-mail and any attachment may contain confidential and privileged material intended for the addressee only. If you are not the addressee, you are notified that no part of the e-mail or any attachment may be disclosed, copied or distributed, and that any other action related to this e-mail or attachment is strictly prohibited, and may be unlawful. If you have received this e-mail by error, please notify the sender immediately by return e-mail, and delete this message. Koninklijke Luchtvaart Maatschappij NV (KLM), its subsidiaries and/or its employees shall not be liable for the incorrect or incomplete transmission of this e-mail or any attachments, nor responsible for any delay in receipt. Koninklijke Luchtvaart Maatschappij N.V. (also known as KLM Royal Dutch Airlines) is registered in Amstelveen, The Netherlands, with registered number 33014286 -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
Gil, I believe that /.^./ or /.$./ both satisfy your requirement. Cheers, Peter Stockdill. -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Paul Gilmartin Sent: Tuesday, 9 July 2013 3:32 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: regex that never matches? Kind of a programming challenge, in view of all the PCRE chatter hereabouts lately: A vendor once supplied an interface where one of the required arguments was a regex to exclude from processing any matching line. But I wanted every line in my data processed. So, how? For my particular data, I could use: /Pattern that I know does not occur in my data/ or: / \000 \012 / ... unlikely to occur in lines processed by sed or awk. But is there a general case: a regex that will never match any string whatever? -- gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
On Wed, 10 Jul 2013 21:33:20 +0800, Peter Stockdill wrote: I believe that /.^./ or /.$./ both satisfy your requirement. On Wed, 10 Jul 2013 08:45:17 -0400, John Gilmore wrote: and he has the right idea. What is needed is a substantive contradiction, one, say, of the logical form ¬(a | ¬a) a ¬a (Redundantly. De Morgan.) that is not so obvious that simple consistency checks catch it. I have tried something similar to Peter's suggestion with mixed results on processors which, as you suspect, variously: o Fail the construct as invalid syntax. o Regard ^ occurring other than at the beginning of a pattern or $ occurring other than at the end of a pattern as unmeta characters. The merely improbable---Something akin to an SQL query of a personnel data base that seeks bilingual Icelandic and Urdu speakers---is not good enough because parochial. Exxon chose its name in part because the roman-alphabet sequence 'xx' is very rare in most natural languages and transliterations, but it turned out to be common in Maltese. And in latter days, some firewalls block anything containing xx (or specialist). For myopia in the other direction, try a DB search for C. I was taught in grammar school that q occurs only followed by u. Before the ascendancy of Middle Eastern politics. -- gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
IBM Mainframe Discussion List IBM-MAIN@LISTSERV.UA.EDU wrote on 07/10/2013 05:40:22 AM: From: Vernooij, CP - SPLXM kees.verno...@klm.com This reminds me of an experiment of a colleague of mine, several years ago. He tried to transform a Rexx program of about one screen of statements into one Rexx statement, using nesting, recursive programming and other fancy stuff. It took him about a week, but he succeeded. Of course it was completely incomprehensible what the statement did, but it worked. he would have loved APL - The information contained in this communication (including any attachments hereto) is confidential and is intended solely for the personal and confidential use of the individual or entity to whom it is addressed. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this communication in error and that any review, dissemination, copying, or unauthorized use of this information, or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. Thank you -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
In 0382727397514044.wa.paulgboulderaim@listserv.ua.edu, on 07/10/2013 at 10:47 AM, Paul Gilmartin paulgboul...@aim.com said: I was taught in grammar school that q occurs only followed by u. Before the ascendancy of Middle Eastern politics. Welsh? -- Shmuel (Seymour J.) Metz, SysProg and JOAT Atid/2http://patriot.net/~shmuel We don't care. We don't have to care, we're Congress. (S877: The Shut up and Eat Your spam act of 2003) -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
does /(?!)/ work for you? Regards, Boris On Tue, July 9, 2013 09:31, Paul Gilmartin wrote: Kind of a programming challenge, in view of all the PCRE chatter hereabouts lately: A vendor once supplied an interface where one of the required arguments was a regex to exclude from processing any matching line. But I wanted every line in my data processed. So, how? For my particular data, I could use: /Pattern that I know does not occur in my data/ or: / \000 \012 / ... unlikely to occur in lines processed by sed or awk. But is there a general case: a regex that will never match any string whatever? -- gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
On Tue, 9 Jul 2013 02:31:31 -0500, Paul Gilmartin wrote: a regex that will never match any string whatever? oh boy, the number of regex I've written that I couldn't get to match even what I could see in front of me :0) Shane ... -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
On Tue, 9 Jul 2013 11:34:55 +0200, Boris Lenz wrote: does /(?!)/ work for you? Thanks! I never woulda thoughta that. Seems to work for sed and grep; nearly an exhaustive sample. Now I need to try to understand it: It matches any string which is not (!) matched by 0 or 1 (?) copies of the null string (which appears between ( and ?). The ( and ) indicate grouping. I have no idea why that's necessary. Perhaps operator precedence? Would any of /(?!)/, /(?)!/, or even /()?!/ work alike? Why not? And, of course, there are many flavors of regex, all with different rules. Thanks again, gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
On Tue, Jul 9, 2013 at 9:56 AM, Paul Gilmartin paulgboul...@aim.com wrote: On Tue, 9 Jul 2013 11:34:55 +0200, Boris Lenz wrote: does /(?!)/ work for you? Thanks! I never woulda thoughta that. Seems to work for sed and grep; nearly an exhaustive sample. Now I need to try to understand it: It matches any string which is not (!) matched by 0 or 1 (?) copies of the null string (which appears between ( and ?). The ( and ) indicate grouping. I have no idea why that's necessary. Perhaps operator precedence? Would any of /(?!)/, /(?)!/, or even /()?!/ work alike? Why not? And, of course, there are many flavors of regex, all with different rules. Thanks again, gil Adjacent special characters (excludes all other characters) that would be extremely rare in actual input? -- Mike A Schwab, Springfield IL USA Where do Forest Rangers go to get away from it all? -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex that never matches?
You're right about the guess why ( is necessary. Simply because the ? needs a precedence. It's a syntax thing. ! does not stand for not. The combination ?! stands for a negative look-ahead. See e.g. perldoc.perl.org/perlre.html for details. Regards, Boris On Tue, July 9, 2013 16:56, Paul Gilmartin wrote: On Tue, 9 Jul 2013 11:34:55 +0200, Boris Lenz wrote: does /(?!)/ work for you? Thanks! I never woulda thoughta that. Seems to work for sed and grep; nearly an exhaustive sample. Now I need to try to understand it: It matches any string which is not (!) matched by 0 or 1 (?) copies of the null string (which appears between ( and ?). The ( and ) indicate grouping. I have no idea why that's necessary. Perhaps operator precedence? Would any of /(?!)/, /(?)!/, or even /()?!/ work alike? Why not? And, of course, there are many flavors of regex, all with different rules. Thanks again, gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex
Thank you... That's ANOTHER thing I'll have to play with (and blog about) when on my residency in October - as I'll have my first sight of a 2.1 system then. I wonder if we'll get to write the Redbook. :-) Cheers, Martin Martin Packer, zChampion, Principal Systems Investigator, Worldwide Banking Center of Excellence, IBM +44-7802-245-584 email: martin_pac...@uk.ibm.com Twitter / Facebook IDs: MartinPacker Blog: https://www.ibm.com/developerworks/mydeveloperworks/blogs/MartinPacker From: Shane Ginnane ibm-m...@tpg.com.au To: IBM-MAIN@listserv.ua.edu, Date: 07/05/2013 11:56 PM Subject:regex Sent by:IBM Mainframe Discussion List IBM-MAIN@listserv.ua.edu I'm afraid I couldn't persist with the (entire) PCRE thread - my bad. From my perspective getting *any* regex into our mundane environment is worthwhile. I can't wait to get the ISPF edit support in 2.1 - I may even start doing stuff on z/OS again instead of zLinux. Where I make extensive use of regex every day. Shane ... -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex
Did IBM promise support for regex in ISPF 2.1? Could you please point me to such announcement? Thanks ZA -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex
On Sun, 7 Jul 2013 00:48:07 -0500, Ze'ev Atlas wrote: Did IBM promise support for regex in ISPF 2.1? Could you please point me to such announcement? http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?subtype=cainfotype=anappname=iSourcesupplier=877letternum=ENUSZP13-0013 The ISPF editor is planned to allow regular expressions to be specified as arguments to the FIND and CHANGE commands. I want to see how they do this, code pages and all (perhaps עִבְרִית?) -- gil -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: regex
On 6/07/2013 6:56 AM, Shane Ginnane wrote: I'm afraid I couldn't persist with the (entire) PCRE thread - my bad. From my perspective getting *any* regex into our mundane environment is worthwhile. I can't wait to get the ISPF edit support in 2.1 - I may even start doing stuff on z/OS again instead of zLinux. Where I make extensive use of regex every day. Hopefully they will add it to SRCHFOR so we can have something similar to grep in ISPF. Shane ... -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN