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:
need regular expression

 



techtween
Novice

Jul 13, 2011, 4:18 AM

Post #1 of 3 (4217 views)
need regular expression Can't Post

i am new to perl, i've a doubt,

I have a text ab_document_1.xml

i need to change it to ab_document_thumb_1.jpg

could you suggest me the regular expression for it.


Amrit
Novice

Jul 19, 2011, 10:56 AM

Post #2 of 3 (3886 views)
Re: [techtween] need regular expression [In reply to] Can't Post

my $a = 'ab_document_1.xml' ;

my $b = 'ab_document_thumb_1.jpg';

$a =~ s/$a/$b/g;

print $a;

can you elaborate your doubt??

are you reading files from directory where you need to modifty the extn for file or change the tail??

Or create blank jpg file ??


miller
User

Jul 22, 2011, 9:37 PM

Post #3 of 3 (3687 views)
Re: [techtween] need regular expression [In reply to] Can't Post


Code
use strict; 
use warnings;

my $file = 'ab_document_1.xml';

$file =~ s/_(\d+)\..*/_thumb_${1}.jpg/;

print $file;


- Miller

 
 


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

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