Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need some Guidance on RegEx

Posted on 2013-12-08
10
Medium Priority
?
259 Views
Last Modified: 2013-12-08
Hi, I need a Code where i can fetch the date of the following format. I am looking for Regular expression but as i am very basic in RegEx, so can't find a way to figure out

21 August , 2010 - 19 March, 2011 

November 14, 2011 - February 30, 2012

Open in new window



The dates and the months and the year can be changed [but the pattern will not change]
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39704049
This grabs the first two dates without the - :

\b\d{2}\s[a-zA-Z]+\s?,\s\d{4}\b

and this grabs the secnd two dates, always without  - :

\b[a-zA-Z]+\s\d{2},\s\d{4}\b
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39704125
i want to grab the both with - sign, how will that be a combination

Regards
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39704145
This for the first:

\b\d{2}\s[a-zA-Z]+\s?,\s\d{4}\s-\s\d{2}\s[a-zA-Z]+\s?,\s\d{4}\b

and this for the second:

\b[a-zA-Z]+\s\d{2},\s\d{4}\s-\s[a-zA-Z]+\s\d{2},\s\d{4}\b
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39704158
Thanks Budy, if you can help more how can i find a string of a link and email address from a string

the following string like

This is the world and i am now testing with the following string. The String is http://www.domain.com/classess/dataformat/anythingbeyon and let us see where we get this. This is the email address of the following, robert junior <a@a.com>

both should be found differently

Regards
0
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 2000 total points
ID: 39704179
This for the url

\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-9+&@#/%=~_|$]

gets http://www.domain.com/classess/dataformat/anythingbeyon from 'The String is http://www.domain.com/classess/dataformat/anythingbeyon and let us see where we get this'

This for the email:

\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}\b

gets a@a.com from robert junior <a@a.com>
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39704184
Hi for url i have this:

(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~##?&//=]+)

i used ## two times as coldfusion will escape one when it gets compiled, but this has a limitation as it checks for http, what if i have https:, ftp or neitehr ftp http or https

please guide
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39704188
The regex I provided above works with all protocols: why don't you use it?
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39704189
Anyway, you can modify your regex this way:

 (((f|ht){1}tp(s)?://)[-a-zA-Z0-9@:%_\+.~##?&//=]+)
0
 
LVL 16

Author Closing Comment

by:Gurpreet Singh Randhawa
ID: 39704190
Thanks Pal
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39704192
Glad to help you! On to the next.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question