The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 9 06-08-2009 06:11 AM
Perl search and replace file content. jxh461 Shell Programming and Scripting 3 04-16-2009 11:26 PM
Search for a string and replace the searched string in the same position in samefile ganesh_248 UNIX for Dummies Questions & Answers 27 03-23-2009 12:35 AM
how can search a String in one text file and replace the whole line in another file kkraja UNIX for Dummies Questions & Answers 6 08-06-2008 07:23 AM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 10:24 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-11-2009
my_Perl my_Perl is offline
Registered User
  
 

Join Date: Jun 2009
Location: India
Posts: 34
How to search a date format from a file an replace with a string in PERL

I am very new to Perl. I am struggling so hard to search a date (such as 10/09/2009, 10-09-2009) from a text file and replace with a string (say DATE) using Perl. Please help me out. Thanks in advance.


Regds

Doren
  #2 (permalink)  
Old 06-11-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,530
provide your sample input and show expected output. help us to help you better.
  #3 (permalink)  
Old 06-11-2009
my_Perl my_Perl is offline
Registered User
  
 

Join Date: Jun 2009
Location: India
Posts: 34
A sample text is "I visited New York on 10-09-2008". The expected output is "I visited New York on DATE". Similary, for another sentence "I visited New York on 10/09/2008". The expected output is "I visited New York on DATE". Also, please help me on how to use regular expression in Perl for such kind of date formats. Thanks in advance.
  #4 (permalink)  
Old 06-11-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,530
Quote:
Originally Posted by my_Perl View Post
Also, please help me on how to use regular expression in Perl for such kind of date formats. Thanks in advance.
perldoc perlretut
  #5 (permalink)  
Old 06-11-2009
my_Perl my_Perl is offline
Registered User
  
 

Join Date: Jun 2009
Location: India
Posts: 34
Thanks a lot. It worked.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:44 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0