Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!uwvax!dogie.macc.wisc.edu!indri!polyslo!csun!csuna!abcscnge From: abcscnge@csuna.csun.edu (Scott "The Pseudo-Hacker" Neugroschl) Newsgroups: comp.sources.wanted Subject: Re: pattern matching Keywords: pattern matching Message-ID: <1974@csuna.csun.edu> Date: 18 May 89 06:46:42 GMT References: <2414@cveg.uucp> Reply-To: abcscnge@csuna.csun.edu (Scott Neugroschl) Organization: CSU Northridge Lines: 32 In article <2414@cveg.uucp> mhb@hcx.uucp (MARK H BOTNER) writes: } }Can anybody help me with pattern matching? I'm trying to match }a string against a pattern such as '*' or '*.*' in the same manner that }the 'ls' command uses. I've tried regex and regexp and I've even downloaded }regex.Z from uunet.uu.net, but none of these work like I want. Actually }I probably only need the wildcard characters '*' and '?', but it wouldn't }hurt to have the full expression syntax that the 'ls' command uses. Thanks! } Your problem is that reg. exprs and the shell wildcarding are different. Regular expressions: . -- match any single character * -- 0 or more of the preceding regex. Shell Wildcarding ? -- match any single character * -- match 0 or more characters. The wildcarding that "ls uses" is not done by ls. It is performed by the shell prior to executing the ls command. If I were in your shoes, I would take the shell wildcard, and translate it to regex form: ? --> . * --> .* and then use the regex stuff. -- Scott "The Pseudo-Hacker" Neugroschl UUCP: ...!sm.unisys.com!csun!csuna.csun.edu!abcscnge -- Beat me, Whip me, make me code in Ada -- Disclaimers? We don't need no stinking disclaimers!!!