This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Please guide me on writing the regex. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Please guide me on writing the regex." Watch "Please guide me on writing the regex." New topic
Author

Please guide me on writing the regex.

kc pradeep
Greenhorn

Joined: Mar 05, 2011
Posts: 28

I have a requirement to replace each ValidDuring('01/18/2011..06/16/2011') in the where condition with (1=1),

So if the query is SELECT * FROM ABCD WHERE ((ValidDuring('2010',date)) and (a>b)) or ValidDuring('01/18/2011..06/16/2011')

then it should be changed to

SELECT * FROM ABCD WHERE ((1=1)and(a>b)) or (1=1)

PS. there are two way of giving input for ValidDuring.

Please let me know how to write a efficient Regex for the same


OCPJP 6
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Assuming the first parameter starts with a single quote, and there are no nested parentheses:


luck, db
There are no new questions, but there may be new answers.
kc pradeep
Greenhorn

Joined: Mar 05, 2011
Posts: 28

This is not giving the correct result, I checked in the site RegExr
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

kc pradeep wrote:This is not giving the correct result, I checked in the site RegExr


Darryl's solution seems to have lost some escaping of the parenthesis.


Maybe when he cut-and-pasted it.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
 
jQuery in Action, 2nd edition
 
subject: Please guide me on writing the regex.
 
Similar Threads
ANdroid Hello World
how to convert gregoriancalendar obj to sqldate?
Multiple Sub-queries. efficient or not ?
java sql help
duplicate created in AUTO INCREMENT in mysql if its possible?