• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OFRegularExpression escape character syntax?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OFRegularExpression escape character syntax?


  • Subject: Re: OFRegularExpression escape character syntax?
  • From: Sherm Pendley <email@hidden>
  • Date: Mon, 11 Nov 2002 22:36:45 -0500

On Monday, November 11, 2002, at 10:17 PM, Michael Norris wrote:

Anyone here used the OFRegularExpression class from the OmniFoundation code? It's working beautifully for most things, but I'm having trouble escaping the period character: doing a matchInString with @"\.+" just returns the entire string, rather than a series (of arbitrary length > 0) of periods.

It looks to me like GCC is interpreting "\." as an escape when compiling your code. Since "." has no special meaning as an escape character, it's used as-is. So, the above string is compiled as ".+" - which would behave as you describe, returning the entire string.

What you need to do is "escape the escape" in GCC, so that it compiles a backslash into your string instead of trying to interpret it as an escape sequence. To do that, use two backslashes, like this: @"\\.+"

sherm--

If you listen to a UNIX shell, can you hear the C?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: OFRegularExpression escape character syntax?
      • From: Michael Norris <email@hidden>
References: 
 >OFRegularExpression escape character syntax? (From: Michael Norris <email@hidden>)

  • Prev by Date: OFRegularExpression escape character syntax?
  • Next by Date: Re: OFRegularExpression escape character syntax?
  • Previous by thread: OFRegularExpression escape character syntax?
  • Next by thread: Re: OFRegularExpression escape character syntax?
  • Index(es):
    • Date
    • Thread