[net.wanted.sources] Magic string pattern matching

ee163ahe@sdcc13.UUCP (VICTOR ROMANO) (02/13/85)

	Does anybody have a procedure/function that compares two strings,
	one which has "magic" wildcards (as in "vi" and "grep")?  For example,
	I need to be able to search for a string that matches some pattern like:

		"beginning .* end"
	
	which would match if it found the string:

		"beginning with some text in the middle end".

	Having both a "search" and a "compare" function would be most useful,
	but I could always make one from the other.

		Thanks,
			Victor Romano.

rcj@burl.UUCP (R. Curtis Jackson) (02/15/85)

> 
> 
> 	Does anybody have a procedure/function that compares two strings,
> 	one which has "magic" wildcards (as in "vi" and "grep")?  For example,
> 	I need to be able to search for a string that matches some pattern like:
> 
> 		"beginning .* end"
> 	
> 	which would match if it found the string:
> 
> 		"beginning with some text in the middle end".
> 
> 	Having both a "search" and a "compare" function would be most useful,
> 	but I could always make one from the other.
> 
> 		Thanks,
> 			Victor Romano.

Well, I would gladly tell you to use the regular expression functions with
Sys V, if I only knew if you were running Sys V.  Something that quite a
few people forget to do in source requests is to provide the following:

Type of computer you are running on (Vax 11/780, 3B20, etc.)
Type and release of operating system (Unix V7, VMS 1.3, BSD 4.2, etc.)

Also, if possible, tell what avenues you may have tried -- for Victor
I would normally say "use lex", since lex is perfect for what he wants.
He may have already tried lex and been confused by it or had some trouble
using it; it'll save both of us time if I know that.

This isn't a poke at you, Victor; just a reminder to people to tell
us in net.wanted.* what type of environment you are working in -- telling
a tire dealer that you want snow tires is pretty useless if he doesn't
know what size you need.

By the way, to make this useful rather than pedantic, I do strongly
recommend lex if you are writing for a specific application.  If you are
looking for generic functions and you have them available, try using
regcmp(3X) and regex(3X) if they are available.
-- 
The MAD Programmer -- 919-228-3313 (Cornet 291)
alias: Curtis Jackson	...![ ihnp4 ulysses cbosgd mgnetp ]!burl!rcj
			...![ ihnp4 cbosgd akgua masscomp ]!clyde!rcj

guido@boring.UUCP (02/17/85)

Sorry, mail couldn't reach you, so I post this to the net (also for general
interest).

Some time ago I posted a similar question to the net.  (It seems to reappear
at regular intervals. :-)  There are various forms of "regular expression
matchers" (probably the best name in a Unix context) in the public domain.
If you have access to a BSD unix version, its "regex(3)" subroutines are
in the public domain (said its author Mark Horton), so you can just use its
source.  (NB System 5's regex(3) is *not* p.d.!!!)
About the same thing is in (also BSD) "more(1)", which is also p.d. (and also
written by Mark Horton).
Other public domain versions occur in James Gosling's Emacs, and in the famous
news reading program "rn" by Larry Wall (who started with Gosling's code).
Finally, there seems to be one available in Richard Stallman's "GNU" (a p.d.
version of Unix, I don't know how much of it is available).
There may also be a (printed) version in Kernighan&Pike.
Mail me for more details -- I don't have a summary readily available but I
can send you all responses I got.

	Guido van Rossum, "Stamp Out BASIC" Committee, CWI, Amsterdam
	guido@mcvax.UUCP