Regular expressions help

Discussion in 'Mac Programming' started by BollywooD, May 11, 2010.

  1. BollywooD macrumors 6502

    BollywooD

    Joined:
    Apr 27, 2005
    Location:
    Surfers Paradise
    #1
    I can't quite get me head around the regex syntax.
    I am trying to loop through a string, removing all specified objects after a "$" symbol, ie:

    Code:
    str = [str stringByMatching:@"\\$(\\~object_subresource| script|,)\\{0,3\\}" replace:RKReplaceAll withReferenceString:@""];
    is there a regex syntax for and/or? in the case of the "$" symbol above, it will match (and remove):

    blahblah$~object_subresource
    blahblah$script

    but not:

    blahblah$~object_subresource,script


    **note: I am using the RegexKit Framework for the matching
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    In terms of a regex just for those matches and ignoring the other,
    Code:
    ^.*\$([\w~]+)$
    will do it.

    I'm not familiar with the code syntax you're using (Objective-C?) so I won't try to incorporate this regex into it as I'd likely screw it up.
     
  3. BollywooD thread starter macrumors 6502

    BollywooD

    Joined:
    Apr 27, 2005
    Location:
    Surfers Paradise
    #3
    many thanks!
     

Share This Page