home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib / misc / pattern.man < prev    next >
Encoding:
Text File  |  1991-05-04  |  2.4 KB  |  86 lines

  1. '\" Copyright 1991 Regents of the University of California
  2. '\" Permission to use, copy, modify, and distribute this
  3. '\" documentation for any purpose and without fee is hereby
  4. '\" granted, provided that this notice appears in all copies.
  5. '\" The University of California makes no representations about
  6. '\" the suitability of this material for any purpose.  It is
  7. '\" provided "as is" without express or implied warranty.
  8. '\" 
  9. '\" $Header: /sprite/lib/forms/RCS/lib.man,v 1.3 91/01/07 17:55:52 mottsmth Exp $ SPRITE (Berkeley)
  10. '/" 
  11. .so \*(]ltmac.sprite
  12. .HS pattern lib
  13. .BS
  14. '\" Note:  do not modify the .SH NAME line immediately below!
  15. .SH NAME
  16. Pattern_Match \- Do csh-style pattern matching and more.
  17. .SH SYNOPSIS
  18. .nf
  19. \fB#include <pattern.h>\fR
  20. .sp
  21. int
  22. \fBPattern_Match\fR(\fIpattern, name\fP)
  23. .SH ARGUMENTS
  24. .AS biggestType biggestName
  25. .AP char *pattern in
  26. Pattern to try matching.
  27. .AP char *name in
  28. Name to try matching against \fIpattern\fR.
  29. .BE
  30.  
  31. .SH DESCRIPTION
  32. .PP
  33. The \fIPattern_Match\fR procedure provides pattern-matching
  34. capabilities for strings.  It understands \fIcsh\fR-style patterns, and
  35. logical \fIand\fR's, \fIor\fR's, and \fInot\fR's with arbitrary levels
  36. of grouping.  To use this procedure,
  37. pass it a string describing the pattern you are trying to match
  38. and a string to test against this pattern.
  39. .PP
  40. If the \fIname\fR argument successfully matches the \fIpattern\fR, the routine
  41. returns the value 0.  If the pattern does not match, it returns 1.  If an
  42. error occurs parsing the pattern, the routine returns -1.
  43. .PP
  44. Pattern_Match uses the following special characters:
  45. .sp
  46. * matches against any number of characters.
  47. .sp
  48. ? matches against any single character.
  49. .sp
  50. [] allows matching against a list of characters enclosed in the []'s, or
  51. against a range of characters as in [a-z].
  52. .sp
  53. \\ allows turning off the magic properties of the special characters
  54. .sp
  55. && requires a match against two patterns
  56. .sp
  57. || allows a match against either of two patterns
  58. .sp
  59. ! forbids a match against the following string
  60. .sp
  61. () allows levels of grouping
  62. .sp
  63. Examples:
  64. .br
  65. "Alice" matches "A*"
  66. .br
  67. "d[efg]" matches "df"
  68. .br
  69. "d[a-z]" matches "dq"
  70. .br
  71. "f?ddle" matches "fiddle"
  72. .br
  73. "f\\?ddle" matches "f\?ddle" but not "fiddle"
  74. .br
  75. "x || y" matches "y"
  76. .br
  77. "x* && *y" matches "xy" but not "frilly"
  78. .br
  79. "(x* && *y) || (frilly) matches "xy" and also "frilly"
  80. .br
  81. "!x* && *y" matches "frilly" but not "xy"
  82. .br
  83.  
  84. .SH KEYWORDS
  85. pattern, matching, string, compare
  86.