Changeset 3614

Show
Ignore:
Timestamp:
03/11/07 01:34:41 (2 years ago)
Author:
timothy
Message:

Allow quoted highlight words so you can have spaces in highlights like 'san francisco'. #971

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Panels/JVDirectChatPanel.m

    r3597 r3614  
    812812                                regex = [AGRegex regexWithPattern:[name substringWithRange:NSMakeRange( 1, [name length] - 2 )] options:AGRegexCaseInsensitive]; 
    813813                        } else { 
     814                                name = [name stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\"'"]]; 
    814815                                NSString *pattern = [NSString stringWithFormat:@"\\b%@\\b", [name stringByEscapingCharactersInSet:escapeSet]]; 
    815816                                regex = [AGRegex regexWithPattern:pattern options:AGRegexCaseInsensitive]; 
  • trunk/Preferences/JVNotificationPreferences.m

    r3418 r3614  
    6262 
    6363- (void) saveHighlightWords:(id) sender { 
    64         // We want to be able to let Regex's contain spaces, so lets split intelligently 
     64        // We want to be able to let highlights contain spaces, so lets split intelligently 
    6565        NSMutableArray *components = [NSMutableArray array]; 
    6666        NSString *words = [highlightWords stringValue]; 
    67         AGRegex *regex = [AGRegex regexWithPattern:@"(?:\\s|^)(/.*?/)(?:\\s|$)"]; 
     67 
     68        AGRegex *regex = [AGRegex regexWithPattern:@"(?<=\\s|^)([/\"'].*?[/\"'])(?=\\s|$)"]; 
    6869        NSArray *matches = [regex findAllInString:words]; 
    6970        NSEnumerator *e = [matches objectEnumerator]; 
     71 
    7072        AGRegexMatch *match = nil; 
    7173        while( ( match = [e nextObject] ) ) 
    7274                [components addObject:[match groupAtIndex:1]]; 
     75 
    7376        words = [regex replaceWithString:@"" inString:words]; 
     77 
    7478        [components addObjectsFromArray:[words componentsSeparatedByString:@" "]]; 
    7579        [components removeObject:@""]; 
     80 
    7681        [[NSUserDefaults standardUserDefaults] setObject:components forKey:@"MVChatHighlightNames"]; 
    7782}