Re: Regex? Need to style portions of text that are not all the same
Re: Regex? Need to style portions of text that are not all the same
- Subject: Re: Regex? Need to style portions of text that are not all the same
- From: David Schneider-Joseph <email@hidden>
- Date: Fri, 29 Jul 2005 12:36:09 -0400
Try the following template:
NSString *s = [@"email@hidden email@hidden" autorelease];
OFRegularExpression *reg = [[[OFRegularExpression alloc]
initWithString:@"\w+@\w+\.\w"] autorelease];
OFRegularExpressionMatch *match = [reg matchInString:s];
while (match) {
NSString *thisMatch = [[match subexpressionAtIndex:0] autorelease];
NSLog(thisMatch);
match = [match nextMatch];
}
On Jul 29, 2005, at 11:18 AM, Paul Harvey wrote:
I know that ARegEx also has a matching class, but from the
available documentation, I can't work out how to implement it.
I've downloaded the OmniFoundation framework, so I'll take a look
over that.
On Jul 29, 2005, at 15:32, David Schneider-Joseph wrote:
Try the free OmniFoundation framework from OmniGroup. It contains
regex-matching classes.
On Jul 29, 2005, at 4:56 AM, Paul Harvey wrote:
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
David Schneider-Joseph
http://www.davidsj.com/
David Schneider-Joseph
http://www.davidsj.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