Regular Expressions in Macromedia HomeSite 5.2

  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Joined: Jan 14, 2004
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada
  • Status: Offline

Post February 24th, 2004, 12:21 pm

Finding regular expression matches in HomeSite using Extended Find works great. I can, for example, match any <meta name="keywords"> line like this:

Code: [ Select ]
<meta name=\"keywords\"[[:print:]]+\">


What doesn't work is using regular expressions in Extended Replace to find a patter and replace it with a pattern + "additional text".

Is this a dead end?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 24th, 2004, 12:21 pm

  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 17, 2004
  • Posts: 279
  • Loc: Buenos Aires, Argentina
  • Status: Offline

Post February 24th, 2004, 2:05 pm

It works perfectly to me:
Code: [ Select ]
Find: src\=\"([a-z\.]+)\"

Replace with: src\=\"/new_path/\1\"
  1. Find: src\=\"([a-z\.]+)\"
  2. Replace with: src\=\"/new_path/\1\"


\1 is the matched string of the first group ()

Results in:

Code: [ Select ]
<img src="my_file.png">

to

<img src="/new_path/my_file.png">
  1. <img src="my_file.png">
  2. to
  3. <img src="/new_path/my_file.png">
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Joined: Jan 14, 2004
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada
  • Status: Offline

Post February 24th, 2004, 2:54 pm

Excellent! Thank you. Now, how about a regular expression that replaces the HomeSite manual with a better one? ;-)

Cheers
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 17, 2004
  • Posts: 279
  • Loc: Buenos Aires, Argentina
  • Status: Offline

Post February 24th, 2004, 5:41 pm

:D hahahaha
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Joined: Jan 14, 2004
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada
  • Status: Offline

Post February 26th, 2004, 9:55 pm

Hey Leo, thanks again. You wouldn't believe how much help that was. I'm regex switching things all over my web site (it has 1000's of files... 1000's!).
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 17, 2004
  • Posts: 279
  • Loc: Buenos Aires, Argentina
  • Status: Offline

Post February 27th, 2004, 6:38 am

I'm glad it helped you. I use them often to such correction tasks.

I think regular expressions are one of the best features of the HomeSite software.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 233 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.