Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Objective-C wildcard?

Objective-C wildcard?
Thread Tools
hyperb0le
Mac Enthusiast
Join Date: Mar 2003
Location: Atlanta, GA
Status: Offline
Reply With Quote
Jan 3, 2004, 12:12 AM
 
I am working on a small learning project. I am currently implementing syntax highlighting that requires a wildcard to be used. For instance, to highlight an <img tag, the code would look for <img + * + >, where * is a wildcard. Is this possible?
     
larkost
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Jan 3, 2004, 12:32 PM
 
You are really unclear in what you want, so I am going to have to do a lot of guessing... Here is what I think you are doing:

You have a NSTextView (Rich Text Enabled) that you want to syntax-hilight. You have gotten the NSMutableAttributedString from the appropriate NSTextStorage object and you would like to find the NSRange of an <img> tag. Do I have things so far?

If so, then you are barking up the wrong tree to try and do this with regular expressions (a wild-card is a regexp concept). You need to create a state machine, or use one of the many html state machines out there.

If you really feel that regexp is the way you need to go, then take a look at OmniGroup's OFRegularExpression in OmniFoundation.
     
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Jan 5, 2004, 12:41 AM
 
Take a look at the NSString methods called something like "rangeOfString..."

Also, the NSScanner class is very good for finding substrings, and identifying their range. It's probably the easiest way to do this sort of thing.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:59 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,