Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Take out the date using Regex.

by muba (Priest)
on Jan 05, 2013 at 11:04 UTC ( #1011778=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Ditch:
    my $string = "Sat, 05 Jan 2013 04:00:15 GMT";
    $string =~ s/\d{2} [A-Z][a-z]{2} \d+ //;
    print "Take out and ditch: $string\n";
    # Output: Take out and ditch: Sat, 04:00:15 GMT
    
  2. or download this
    # Keep around:
    my $string = "Sat, 05 Jan 2013 04:00:15 GMT";
    my ($match) = $string =~ m/(\d{2} [A-Z][a-z]{2} \d+)/;
    print "Take out and keep: <$match> found in <$string>\n";
    # Output: Take out and keep: <05 Jan 2013> found in <Sat, 05 Jan 2013 
    +04:00:15 GMT>
    
  3. or download this
    # Ditch:
    my $string = "Sat, 05 Jan 2013 04:00:15 GMT";
    substr($string, 5, 12, "");
    print "Take out and ditch: $string\n";
    # Output: Take out and ditch: Sat, 04:00:15 GMT
    
  4. or download this
    # Keep around:
    my $string = "Sat, 05 Jan 2013 04:00:15 GMT";
    my $match = substr($string, 5, 11); 
    print "Take out and keep: <$match> found in <$string>\n";
    # Output: Take out and keep: <05 Jan 2013> found in <Sat, 05 Jan 2013 
    +04:00:15 GMT>
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1011778]
help
Chatterbox?
[GotToBTru]: so I emailed my contact asking if we could just stop sending it .. I'm afraid she is going to ask "what is that anyway?"
[MidLifeXis]: heh.
[MidLifeXis]: Most likely it is a code that some undocumented system, hidden behind layers of IT, deep in the bowels of the building under the machine room floor, reads that code to keep a presence switch from going off. :-b
[MidLifeXis]: I think I forgot "running on a farm of commodore 64, vic 20s, trs 80s, and apple ]|[e systems"
[GotToBTru]: oh I know what it is .. but it is a number only slightly useful to me and of no possible use to our customer
[MidLifeXis]: Whew - you just saved the free world. <o)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2017-01-20 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (176 votes). Check out past polls.