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 > Tag Selection

Tag Selection
Thread Tools
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
May 23, 2007, 08:22 AM
 
I have long since forsaken Dreamweaver in favor of hand-coding and I'm very happy with that decision; however, one feature of DW I miss is the ability to search/select/replace entire tags (without selecting anything inside the tag), including the closing tag when needed. Is there any other program that does this? I don't see a way to do it in TextWrangler. I also seem to recall that you can also search/select/replace HTML/XML attributes as well -- very useful in Web development.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 23, 2007, 09:38 AM
 
TextMate?
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
May 23, 2007, 10:50 AM
 
Originally Posted by Chuckit View Post
TextMate?
Yes, but Textmate costs £39 ($77.28 US), and TextWrangler is free.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 23, 2007, 02:34 PM
 
Actually, TextMate costs €39, which is about $50. Anyway, you didn't ask about prices; you asked what program could do it. TextWrangler can't do it as far as I am aware, so I didn't mention that.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
May 23, 2007, 02:46 PM
 
Originally Posted by Chuckit View Post
Actually, TextMate costs €39, which is about $50. Anyway, you didn't ask about prices; you asked what program could do it. TextWrangler can't do it as far as I am aware, so I didn't mention that.
Of course, you're right, no problem. I blew it -- it was Euros, not pounds sterling -- my bad. But price is a factor for me as my thinking on this evolves.
(Last edited by selowitch; May 23, 2007 at 02:56 PM. )
     
Addicted to MacNN
Join Date: Mar 2006
Status: Offline
Reply With Quote
May 23, 2007, 03:36 PM
 
How much is Dreamweaver though? Seems like TW would be a cheap option.
     
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
May 23, 2007, 03:39 PM
 
Doesn't TextWrangler support regexes? I'd be surprised if it doesn't.
     
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
May 23, 2007, 03:45 PM
 
Originally Posted by Mithras View Post
Doesn't TextWrangler support regexes? I'd be surprised if it doesn't.
It does, but search strings for locating tags aren't predefined, and I don't think you can simultaneously select more than one noncontiguous string. For example, for this code:
[codex]<a href="/somelink/">Some anchor text</a>[/codex]
I'd like to search/select/replace this:
[codex]<a href="/somelink/">[/codex]
and this:
[codex]</a>[/codex]
at the same time, without selecting
[codex]Some anchor text[/codex]
... which is what DW can do just by double-clicking.
Originally Posted by peeb View Post
How much is Dreamweaver though? Seems like TW would be a cheap option.
I don't care. I wouldn't go back to DW if Adobe paid me.
(Last edited by selowitch; May 23, 2007 at 03:54 PM. )
     
Addicted to MacNN
Join Date: Mar 2006
Status: Offline
Reply With Quote
May 23, 2007, 04:24 PM
 
I don't care. I wouldn't go back to DW if Adobe paid me.
Well sure, it just seemed that if you could afford DW, you could probably shell out the fifty bucks for TW.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 23, 2007, 04:37 PM
 
Regexp for replacing the tag should be something like:

Find: <(tagname) restoftag>(.*)</\1>
Replace: <replacementtag>\2</replacementtag>

Insert the tag you want to replace where "tagname" is (including parens), the rest of the tag where restoftag is and the replacement tag…well, you get it.

It's not really a ridiculously elegant solution, but it will replace all occurrences of a tag without messing up your text.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Mac Elite
Join Date: Nov 2003
Location: Rockville, MD
Status: Offline
Reply With Quote
May 23, 2007, 05:02 PM
 
Originally Posted by Chuckit View Post
Regexp for replacing the tag should be something like:

Find: <(tagname) restoftag>(.*)</\1>
Replace: <replacementtag>\2</replacementtag>

Insert the tag you want to replace where "tagname" is (including parens), the rest of the tag where restoftag is and the replacement tag…well, you get it.

It's not really a ridiculously elegant solution, but it will replace all occurrences of a tag without messing up your text.
Thanks. That's very helpful!
Originally Posted by peeb View Post
Well sure, it just seemed that if you could afford DW, you could probably shell out the fifty bucks for TW.
Surely you mean TM. And I already have DW, but I don't like to use it ever, because it messes up and fattens my code.
     
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
May 23, 2007, 06:15 PM
 
Though you'd probably want that to be
[codex]<(tagname) restoftag>([^<]*)</\1>[/codex]

or (if it supports Perl-style nongreedy regexes)
[codex]<(tagname) restoftag>(.*?)</\1>[/codex]

...since otherwise you'll swallow everything between the first <a> and last </a>, which is probably not what you want...
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 23, 2007, 06:21 PM
 
The first option there will break on any element that's not completely simple (<i><b></b></i>, for example, could not replace the I tags). The non-greedy version works, and is in fact what I meant to do. Though both versions seem to be non-greedy in TextWrangler anyway.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:50 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2