CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Regular expression



Jun 21, 2000, 12:14 AM

Post #1 of 3 (460 views)
Regular expression Can't Post


Plase help me to understand the meaning of the "!" in this regular expression.
$file =~ s!</TITLE>.*</HEAD>!</TITLE>\n$meta!isx;

It seems like they are replacing the "/", but I can't find information anywhere about the exact meaning.



Jun 21, 2000, 7:51 AM

Post #2 of 3 (460 views)
Re: Regular expression [In reply to] Can't Post

The delimiter "/" in the substitution operation s/PATTERN/REPLACEMENT/ can be replaced by any non-alphanumeric, non-whitespace delimiter, basically - as described in perlop.
There is no special significance for the "!" (but there is one for the delimiter "'").

The advantage of using something else than "/" (e.g. "!" here) is that you don't need to escape (backslash) the "/" characters that may appear inside the pattern or the replacement part.
Handy for directories, or HTML code Smile


Jun 21, 2000, 1:16 PM

Post #3 of 3 (460 views)
Re: Regular expression [In reply to] Can't Post

Just a note, while almost all non-alphanumeric non-whitespace characters will work, ? will not. ?'s are used for a specific type of search.

Also, while I'm posting, I seem to recall that if you use containing symbols (parenthesis, brackets and braces) you use them in pairs....

instead of s/was/now/
it would be s(was)(now)

.... but I could be wrong about that.

Dr. Zed


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives