Link to home
Start Free TrialLog in
Avatar of Coast Line
Coast LineFlag for Canada

asked on

Need some Guidance on RegEx

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]
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

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
Avatar of Coast Line

ASKER

i want to grab the both with - sign, how will that be a combination

Regards
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
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
ASKER CERTIFIED SOLUTION
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
The regex I provided above works with all protocols: why don't you use it?
Anyway, you can modify your regex this way:

 (((f|ht){1}tp(s)?://)[-a-zA-Z0-9@:%_\+.~##?&//=]+)
Thanks Pal
Glad to help you! On to the next.