Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


String Modifiers

String Modifiers

  • Finally, pattern matching can be used to modify strings of text. One of the most common methods of modification is substitution. Substitution is performed using the format

    s/[pattern_to_find]/[pattern_to_replace_with]/
    

  • Thus, for example, the line:

    s/eric/selena/ 
    

  • would change the line

    eric is my name 
    

    to

    selena is my name 
    

  • The substitution function is modified most commonly with the /i and the /g arguments. The /i argument specifies that matching should be done with case insensitivity and the /g specifies that the match should occur globally for the entire string of text rather than just for the first occurrence.

  • Thus, the line

    s/eric/selena/gi 
    

    would change the line:

    I am Eric, eric I am 
    

    to

    I am selena, selena I am 
    

  • without the /i, you would get

    I am Eric, selena I am 
    

  • and without /g but with the /i, you would get

    I am selena, eric I am 
    

  • There are many, many different kinds of matching operators, anchors, and string modifiers. If you want a more detailed explanation I recommend that you find a good reference source on Regular Expressions. Otherwise, the above discussion should explain how operators and anchors are commonly used in CGI applications.

Additional Resources:

Anchors
Table of Contents
The =~ operator


Up to => Home / Authoring / Scripting / Tutorial




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers