Forums / Setup & design / Manipulate string with regexp?

"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".

Manipulate string with regexp?

Author Message

Eivind Marienborg

Monday 11 December 2006 6:06:45 am

Hi!

<b>Short version:</b>
Is there any way to use regexp to manipulate text strings (e.g. <i>$nick =~ s/[^a-zA-Z0-9]+//g</i>) in eZ? If so, how?

<b>Long version:</b>
I'm setting up a chat section on our community site, using CGI::IRC and a local installation of ircd-ratbox. I want my users to have the same nickname both in eZ and on irc, and to do that, I generate the login-form from CGI::IRC myself, putting the eZ username (not the user account-username, but a normal text line-field (in order to allow more dynamic usernames)) in a hidden form-field. (The users are not allowed to alter nicknames on IRC, by restrictions in CGI::IRC and ratbox)

The problem is that since our username-field allows special characters (~ > < _ %" etc), the login to irc fails.

So, I need to strip of the special characters (<i>$nick =~ s/[^a-zA-Z0-9]+//g</i>) . There is a theoretical possibility of doing this in IRC::CGI after the form is submitted, but if eZ can handle it, that would be easier.

Any ideas on how this could be done?

Kristof Coomans

Monday 11 December 2006 7:44:20 am

Hi Eivind

Did you try the reg ex replace contribution: http://ez.no/community/contribs/template_plugins/reg_ex_replace ?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Eivind Marienborg

Monday 11 December 2006 10:11:42 am

ah, works great! thanks for the tip, and sorry I missed that page when searching.