This is MiscStringPatterns.h in view mode; [Download] [Up]
// // MiscStringPatterns.h -- Pattern matching and replacement routines // Written by Steve Hayman Copyright (c) 1994 by Steve Hayman. // Version 1.95 All rights reserved. // This notice may not be removed from this source code. // // This object is included in the MiscKit by permission from the author // and its use is governed by the MiscKit license, found in the file // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file // for a list of all applicable permissions and restrictions. // //#import <misckit/MiscString.h> // Note from Don: these are here "temporarily" until we can get the regexpr.c // routines wrapped up by a few methods. That's being done by Carl Lindberg // as he gets the time to do it. @interface MiscString(PatternMatching) /* * Pattern matching and replacement routines * These methods match MiscStrings against regular expressions, and * perform substitutions. * Steve Hayman * shayman@Objectario.com */ /* * See if the receiver matches a regular expression. * Returns 1 if it matches, 0 if not, -1 if an invalid regular expression. * caseSens says whether or not to do case-sensitive matching. */ #ifdef DONT_COMPILE // obsoleted by Regex category - (int) grep:(const char *)pattern; #endif #ifdef DONT_COMPILE // obsoleted by Regex category - (int) grep:(const char *)pattern caseSensitive:(BOOL)caseSens; #endif /* * Match a regular expression as above, and optionally split it * into three substrings - the part before the match, the part * that actually matched the pattern, and the part after the match. * bstring, mstring and astring should be other allocated MiscString objects * which will be filled in by this method. */ #ifdef DONT_COMPILE // obsoleted by Regex category - (int) grep:(const char *)pattern caseSensitive:(BOOL)caseSens before:bstring middle:mstring after:astring; #endif /* * The same pattern matching methods as above, only with MiscString * patterns rather than (const char *) patterns. */ - (int) grepString:pattern caseSensitive:(BOOL)caseSens before:bstring middle:mstring after:astring; - (int) grepString:pattern; - (int) grepString:pattern caseSensitive:(BOOL)caseSens; /* * Search-and-replace, with patterns. * Searches for occurrences of the regexp "pattern" in the destination string, * replaces it with "replacement". * If glob is YES, replace all pattern occurrences; if NO, only the first. * Returns the number of replacements that were made. * Returns -1 if an ill-formed pattern was supplied * */ - (int)replacePattern:(const char *)pattern caseSensitive:(BOOL)caseSens globally:(BOOL)glob with:(const char *)replacement; - (int)replacePattern:(const char *)pattern caseSensitive:(BOOL)caseSens globally:(BOOL)glob withString:replacement; - (int)replacePatternString:pattern caseSensitive:(BOOL)caseSens globally:(BOOL)glob with:(const char *)replacement; - (int)replacePatternString:pattern caseSensitive:(BOOL)caseSens globally:(BOOL)glob withString:replacement; @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.