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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Matching and Replacing : in line

 



lapsan
Deleted

Aug 11, 2000, 8:39 AM

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

<p>Hello.

<p>I have the following:

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

<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 = "";
}
</pre>

<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?

Thanks


dws
Deleted

Aug 11, 2000, 9:35 AM

Post #2 of 2 (2432 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:

/^[A-Z]{5,}/



 
 


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

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