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: Intermediate:
Regex Help Please

 



berm
Novice

Feb 10, 2007, 5:13 PM

Post #1 of 3 (385 views)
Regex Help Please Can't Post

Hi, I am making a search engine.
I want to make bold the query by the user. Regardless of what case they use and regardless of what case the result is.
The end result should be <b>Motorhomes</b> and Caravans

Heres what I have so far:

$q = "MOTORHOMES";

$Title = "Motorhomes and Caravans";


(This post was edited by berm on Feb 10, 2007, 5:42 PM)


KevinR
Veteran


Feb 10, 2007, 10:41 PM

Post #2 of 3 (382 views)
Re: [berm] Regex Help Please [In reply to] Can't Post

well, thats not very much. But anyways:


Code
$q = "MOTORHOMES"; 
$Title = "Motorhomes and Caravans";
$Title =~ s/\b($q)\b/<b>$1<\/b>/gi;
print $Title;


I recommend you read this online book, maybe start with chapter 5:

http://www.perl.org/books/beginning-perl/
-------------------------------------------------


berm
Novice

Feb 11, 2007, 4:12 AM

Post #3 of 3 (379 views)
Re: [KevinR] Regex Help Please [In reply to] Can't Post

Thanks very much!Wink

 
 


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

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