home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / rexx / 939 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  3.0 KB

  1. Path: sparky!uunet!mcsun!uknet!comlab.ox.ac.uk!imc
  2. From: imc@comlab.ox.ac.uk (Ian Collier)
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: Regular expression syntax
  5. Message-ID: <2414.imc@uk.ac.ox.prg>
  6. Date: 8 Sep 92 16:12:49 GMT
  7. References: <19920908084344SEB1525@MVS.draper.com>
  8. Organization: Oxford University Computing Laboratory, UK
  9. Lines: 55
  10. X-Local-Date: Tuesday, 8th September 1992 at 5:12pm BST
  11. Originator: imc@msc2.comlab
  12.  
  13. In article <19920908084344SEB1525@MVS.draper.com>, SEB1525@MVS.draper.com (Steve Bacher) wrote:
  14. >Now that the idea has been seriously suggested, why don't we try to
  15. >come up with a nice REXXy syntax for regular expressions?
  16.  
  17. >How about this to kick off a discussion...
  18.  
  19. > Unix-style regexp                Proposed REXX-style expression
  20. >
  21. >  abc                             "abc"
  22. >  a.c                             "a" ANY "c"
  23. >  a*                              ZERO_OR_MORE("a")
  24. >  a.*                             "a" ZERO_OR_MORE(ANY)
  25. >  a[bc]d  (them's sq. brackets)   "a" ("b" OR "c") "d"
  26. >  ^abc                            BEGIN "abc"
  27. >  abc$                            "abc" END
  28.  
  29. Sorry, but I don't think this is "REXXy".  Apart from anything else,
  30. ZERO_OR_MORE("a"), as well as being rather too verbose IMHO, looks like a
  31. function call but isn't.  What kind of animal is it anyway? (note, I'm not
  32. asking what it does, but what "part of speech" it is in Rexx).
  33.  
  34. Remember, we do already have some symbols, notably & (and) and | (or).
  35. That's not to say that I would prefer ".+" over any other method of notating
  36. "one arbitrary character or more", however, just that I don't think you are
  37. justified in using "OR" as a reserved word in patterns.
  38.  
  39. >Then we could have a function MATCH(string,pattern) where pattern
  40. >is a regexp as above.  And we could have PARSE PATTERN pattern WITH...
  41.  
  42. I'd prefer to limit regular expressions to builtin functions, if we are to
  43. have them at all, really.  Anyway, we might have trouble with the PARSE
  44. syntax if we were to want to know which character represented the "." and
  45. ".*" in "foo. .*blah".
  46.  
  47. I think we are (mainly) wanting to provide regular expressions for unix
  48. users who are familiar with them.  I've programmed in Rexx for years and
  49. never wanted one (though I have used them in other contexts, e.g. in awk).
  50. Therefore I suggest that a syntax familiar to those users (e.g. in the
  51. style of "egrep" et al, but certainly not emacs!) be used, rather than an
  52. artificially Rexx-ized version.  It may not seem particularly obvious to you
  53. to type something like
  54.  
  55.   call match input,"foo(.) (.*)blah$","x","y"            [*]
  56.  
  57. but I'm sure the unix-types will love it (no disrespect, of course). ;-)
  58.  
  59. Ian Collier
  60. Ian.Collier@prg.ox.ac.uk | imc@ecs.ox.ac.uk
  61.  
  62. [*] In this example, the first parameter is the string to be matched, the
  63. second parameter is the regular expression, and the subsequent parameters
  64. are the names of variables to be assigned with the substrings which matched
  65. parenthesised expressions in the pattern, namely "." and ".*" respectively.
  66. Some value indicating the amount of success of the match will probably be
  67. returned from the function.
  68.