Regular expression for inserting correct operator

Author Message

Trond Åge Kvalø

Thursday 29 January 2004 8:22:47 am

Consider the following block of text:

images/navbar_images/navbar4/navbar_hpp4_r2_c11_f3.gif

This is an image used in one of my two javascript pop-up menus created with macromedia fireworks. I have somewhere about 100 or even more references to images that constitute my menus.

They all start with "images/" and end with ".gif" but have different things in between.

Now I want to change all of those into:

{images/navbar_images/navbar4/navbar_hpp4_r2_c11_f3.gif|ezimage}

That is insert "{" at the beginning and append "|ezimage}" to the end.

Can anyone please help me with the regular expression for this?

Best regards
Trond Åge Kvalø
Senior develolper
Atlantia as
http://www.atlantia.no/

trondåge

Trond Åge Kvalø

Friday 30 January 2004 5:56:42 am

This regular expression might do the trick, although I'm a bit insecure about whether { | and } are special characters that need escaping.

s/(images\/[^,\n]+\.gif)/\{($1)\|ezimage\}/

which in terms of dreamweaver is to put

(images\/[^,\n]+\.gif) in the Find:-field

and

{$1|ezimage} in the Replace:field

and check the Use regular expression checbox

As mentioned I use DreamWeaver and Fireworks as my HTML and image editors. I usually create my design in plain html files using dummy text etc to see how it will look in real life. Then I insert the eZ template codes at the appropriate places in my design.

With Fireworks it's easy as pie to create nice looking JavaScript pop-up menus. The only caveat is that it creates many different references to the images that makes up the navbar. For my two pop-up menus There where 177 instances that needed to change to use the ezimage operator.

Thanks to this regular expression it's now quite easy to incorporate whatever design I want.

Best regards
Trond Åge Kvalø
(No, I'm not schizofrenic. I just found the solution myself, but wanted to share it :-)

trondåge

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:30:25
Script start
Timing: Jan 18 2025 19:30:25
Module start 'layout'
Timing: Jan 18 2025 19:30:25
Module start 'content'
Timing: Jan 18 2025 19:30:25
Module end 'content'
Timing: Jan 18 2025 19:30:25
Script end

Main resources:

Total runtime0.0303 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 588.0469152.6406
Module start 'layout' 0.00790.0041 740.687539.4922
Module start 'content' 0.01210.0158 780.179789.2578
Module end 'content' 0.02790.0024 869.437530.3047
Script end 0.0303  899.7422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003110.0657140.0002
Check MTime0.00134.2096140.0001
Mysql Total
Database connection0.00072.420910.0007
Mysqli_queries0.004314.065430.0014
Looping result0.00000.092010.0000
Template Total0.00185.910.0018
Template load0.00103.205610.0010
Template processing0.00082.724410.0008
Override
Cache load0.00072.219610.0007
General
dbfile0.00082.578280.0001
String conversion0.00000.035440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs