Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 8th, 2011, 05:49 AM
madhu542 madhu542 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 19 madhu542 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 18 m 37 sec
Reputation Power: 0
Pattern Matching For Date and Long/Lati

Need help...
in pattern matching for Date(mm/dd/yy , dd/mm/yy)and latitude/longitude
I have tried as bellow but date will be matched as lat/lng because of delimiter "/"
Date should have delimiter as [/ - ] and lat/long should have [ , : ; /]
dbarray=( 8/Dec/2010@@@456/1145@@@-@@@- )
for i in ${dbarray[@]}; do
if [[ $i =~ ^({(0[1-9]|1[012]|\D)\.(0[1-9]|[12][0-9]|3[01])\.(19/20)[0-9]+$})|^({(0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012]|\D)\.(19|20)[0-9]+$}) ]]; then
Installer=$i
elif [[ $i =~ (^[0-9]+).+([0-9]+)$ ]]; then
lat_lng=$i
fi
done
Can anybody help me out from this... to test Date and long/latitude correctly !
Thanks,

Reply With Quote
  #2  
Old February 8th, 2011, 06:44 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 41 m
Reputation Power: 1485
Your requirement is ... well, horrible! Matching dates is bad enough without rolling in the fact that you'll accept dd/mm as well as mm/dd, with the month component also being an alpha abbreviation and the day having, or not, a leading zero.
I made a start, but gave up when my eyes started bleeding from trying to match up all the brackets as I started to build up the needed regex: and that was until (but not including the first year field!).
Don't try and be clever is my suggestion - go for basic checks and assume that the data is good, so look for 1 or 2 numerics, followed by a / or -, then one or two numerics (or 3 alpha) followed by a / or -, then 2 or 4 numerics and assume if that pattern matches it's a date, and so on.
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Pattern Matching For Date and Long/Lati

Developer Shed Advertisers and Affiliates



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap