• 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
Regex? Need to style portions of text that are not all the same
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Regex? Need to style portions of text that are not all the same


  • Subject: Regex? Need to style portions of text that are not all the same
  • From: Paul Harvey <email@hidden>
  • Date: Fri, 29 Jul 2005 09:56:09 +0100

Hello All.

I have text in an NSTextView that I want to style with different fonts and colours. Each paragraph begins with a paragraph number, for example:

1 This is the first paragraph.
2 This is the next one.
3 Here's another and there are usually more.

I want to be able to pick out the numbers and style them in a different font, size and color. I've got ARegEx in my app, and am using it successfully to alter other parts of the text. I've also go a loop going, using an NSScanner and searching for specific words so I can style those as needed.

I know I can use NSRange to select text and style it, but I can't work out how best to deal with this situation, where the source is not a single word but different numbers. Apart from the first number, all the others happen after a carriage return, so I'm looking for that plus whatever the number/s are after it.

I guess I'm looking for a routine that can take a RegEx search string (something like "\r[0-9]+") and return it's position and length as a range. Am I asking for too much?..!

--
Paul Harvey

Lead Programmer
email@hidden

Hiddenfield Software
"Creating useful software for Mac OS X"
www.hiddenfield.com


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Regex? Need to style portions of text that are not all the same
      • From: David Schneider-Joseph <email@hidden>
  • Prev by Date: Re: Cocoa and Apple Event
  • Next by Date: Re: [Core Data - Newbie] Custom validation method called twice.
  • Previous by thread: Re: NSTextView "Multiple fonts allowed" setting programatically
  • Next by thread: Re: Regex? Need to style portions of text that are not all the same
  • Index(es):
    • Date
    • Thread