Sponsored Content
Top Forums Shell Programming and Scripting Required help in perl regular expression substitution for this date format Post 302534112 by sarbjit on Monday 27th of June 2011 03:51:33 AM
Old 06-27-2011
Error Required help in perl regular expression substitution for this date format

Hi,

I have written a small perl script to handle particular date format using perl, but it is not substituting the whole string. Can some one please check on what is the issue with the code.

Code:
$_ = "Date: November 25, 2010  09:02:01 PM";
if(s/\(January|February|March|April|May|June|July|August|September|October|November|December\) *[0-3]*[0-9], *[0-9]*[0-9][0-9] *[0-2]?[0-9]:[0-5][0-9]:[0-5][0-9]\(\.[0-9][0-9]\)? *[AP]M/DATE***/g) {
$flag = 1;
print "Done";
print $_;
}

It is giving the following output:
DoneDate: DATE*** 25, 2010 09:02:01 PM

I want whole of this date to be substituted with DATE***
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

regular expression format

. . . AA = 0.000000, 0.000000, 0.006000, 0.006000, 1, 1.000000, 0.000000 ;item 1 #line 1 BB = -0.002990, -0.002990, 0.002990, 0.002990, 0, 1.000000, 0.000000 ;List 1 #line 2 CC = 0.023620, 0.023620, 0.035430, 0.035430, 1, 1.000000, 0.000000 ;Counter strike ... (1 Reply)
Discussion started by: trynew
1 Replies

2. Shell Programming and Scripting

regular expression format string in one line.

Hi All, @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); $day=091023; $day_combine = $day; $day_combine =~ s/({2})({2})({2})/20$1-$months-$3/; Instead of three lines, is possible to combine the last two lines into a single line? means no need assign $day to $day_combine... (2 Replies)
Discussion started by: jimmy_y
2 Replies

3. Shell Programming and Scripting

Regular expression (regex) required

I want to block all special characters except alphanumerics.. and "."(dot ) character currently am using // I want to even block only single dot or multiple dots.. ex: . or .............. should be blocked. please provide me the reg ex. ---------- Post updated at 05:11 AM... (10 Replies)
Discussion started by: shams11
10 Replies

4. Shell Programming and Scripting

perl regular expression format date

Hi Everyone, Mon 18 Jan 2010 09:52:10 AM MYT the output is 20100118 09:52:10 how to do it in perl regular expression =~ Thanks (3 Replies)
Discussion started by: jimmy_y
3 Replies

5. Shell Programming and Scripting

validate date pattern using Regular Expression

Hi, i am java guy and new to unix. I want to validate date pattern using Regex expression here is the sample program i have written. #!/bin/sh checkDate="2010-04-09" regex="\\d{4}-\\d{2}-\\d{2}\$" echo $regex if ] then echo "OK" else echo "not OK" fi But the ouput is... (2 Replies)
Discussion started by: vvenu88
2 Replies

6. Shell Programming and Scripting

Hidden Characters in Regular Expression Matching Perl - Perl Newbie

I am completely new to perl programming. My father is helping me learn said programming language. However, I am stuck on one of the assignments he has given me, and I can't find very much help with it via google, either because I have a tiny attention span, or because I can be very very dense. ... (4 Replies)
Discussion started by: kittyluva2
4 Replies

7. Shell Programming and Scripting

Perl regular expression help!

Hi I am doing something basic like... if ($stringvariable =~ /have not typed/) I have a little problem because the 'not' in the expression gets highlighted as a kind of a '!'..what am I supposed to do in this situation? Thank you ---------- Post updated at 03:24 PM ----------... (1 Reply)
Discussion started by: vas28r13
1 Replies

8. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

9. Solaris

Regular Expression in Date ls command

Hi, I have got a problem in a regular expression with a file name containing date. I am using a regular to display the file in ls, but by using the same it gives me file name does not exist. --## File exist when I do ls. ls amey_in20131018.csv --## File name not showing when I use... (5 Replies)
Discussion started by: ameyrk
5 Replies

10. Shell Programming and Scripting

Help required in writing the regular expression.

1 1982 1 testing init.cc 3001 Apr 25 2014 09:56:13.617 Task(0x5bac5060) tRestart (stack st:0x5bace000, end:0x5bac8000) deleted 1 1982 1 testing init.cc 3001 Apr 25 2014 09:56:13.628 Task(0x5bac5060) tRestart (stack st:... (12 Replies)
Discussion started by: VSSajjan
12 Replies
DM_DATE(1)						User Contributed Perl Documentation						DM_DATE(1)

NAME
dm_date - print out the system date and time SYNOPSIS
This performs the same operation as the unix 'date' command, but using the Date::Manip module. dm_date [OPTION]... [+FORMAT] DESCRIPTION
This displays information about the current system time, or some other time. Options are: -h, --help Print online help. -d STRING, --date=STRING Display time described by STRING. STRING can be any string which can be parsed by Date::Manip. Please refer to the Date::Manip::Date documentation for details. -f DATEFILE, --file=DATEFILE This reads each line in DATEFILE, and extracts a date from it and prints out the information. Blank lines and lines starting with a pound (#) are ignored. Lines not containing a valid date are also ignored. -r FILE, --reference=FILE Displays the last modification time of FILE. -R, --rfc-2822 Displayc the date and time in RFC 2822 format. Example: Mon, 07 Aug 2006 12:34:56 -0600 -u, --utc, --universal Converts the date to UT (GMT) and prints out the information. Only one of -d, -f, or -r should be included. If more than one is included, the first one from the list (-d, -f, -r) is used and any other is ignored. The format string starts with a plus (+) and contains any of the format directives described in Date::Manip::Date. KNOWN BUGS
None known. BUGS AND QUESTIONS
Please refer to the Date::Manip::Problems documentation for information on submitting bug reports or questions to the author. SEE ALSO
Date::Manip::Date LICENSE
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR
Sullivan Beck (sbeck@cpan.org) perl v5.16.3 2014-06-09 DM_DATE(1)
All times are GMT -4. The time now is 01:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy