Live coverage of Fall Internet World '99! logo

internet.com
Join the free
WDVL newsletter!

home

The =~ operator

The =~ operator

  • Pattern matching can also be used to manipulate variables. In particular, many CGI scripts take advantage of the "=~" operator in conjunction with the substitution operator using the format

    $variable_name =~
    s/[string_to_remove]/[string_to_add]/gi; 
    

  • For example, if we want to censor every occurrence of the word "Frack" from the client-defined input field "comment", we might use the line

    $form_data{'comments'} =~ s/frack/censored/gi; 
    

Additional Resources:

String Modifiers
Table of Contents
Using the split and join functions

Up to => Home / Authoring / Scripting / Tutorial

Instantly look up a "techie" word using Webopedia!!


internet.com
e-commerce
WebDeveloper Network



Copyright 1999 internet.com Corporation. Legal Notices. Privacy Policy.

www.internet.com