Forums / Developer / Regular expression for inserting correct operator

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

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