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: Regular Expressions:
Matching and Replacing : in line



Aug 11, 2000, 8:39 AM

Post #1 of 2 (6673 views)
Matching and Replacing : in line Can't Post


<p>I have the following:

<pre> if ($filename =~ m/^{5,}[A-Z]./) {
$section_title = ($filename =~ s/[:]?/':</B>\n<BR><BR>'/);
$filename = "";

<p>And it doesn't work. I want it to replace the colon it finds on lines
that have the first five characters written in CAPS and replace it with
the colon as well as some HTML.

<p>I've also tried this:

<pre> if ($filename =~ m/^{5,}[A-Z]./) {
$section_title = ($filename =~ s/?[:]./':</B>\n<BR><B>\n'/);
$filename = "";

<p>That doesn't work either.

<p>I'm new to regular expressions have been searching for some helpful
information on this problem all over the place. Even went so far as to
try to use the Reg. Expression used in the Perl Cookbook for parsing
text files by comma seperated data.

<p>Anyone have any suggestions?



Aug 11, 2000, 9:35 AM

Post #2 of 2 (6673 views)
Re: Matching and Replacing : in line [In reply to] Can't Post

The way to match at least 5 capital letters at the beginning of a string is:



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

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