This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.

Srikanth Madasu

Ranch Hand
+ Follow
since Sep 10, 2008
Srikanth likes ...
Hibernate Eclipse IDE Spring
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Srikanth Madasu

Then I suppose there is no way I can do it using regex.

I think I can come up with my own parser. First splitting the string on first space. and then apply split on quote followed by space.

Do you think of any other elegant way to do it?

And thanks for your time!
6 years ago
I have a String with pattern KEYWORD ARG1="x" ARG2="test test" that I need to tokenize. I tried using  Pattern. It gives first 2 groups and gives exception after that. Any help is appreciated. Thanks.


I get this output:

Exception in thread "main" java.lang.IndexOutOfBoundsException: No group 3
at com.fepoc.fepdirect.shakeout.main.util.CommandParser.parseCommand(
at com.fepoc.fepdirect.shakeout.main.util.CommandParser.main(

6 years ago
Thanks Henry.

It worked. Just changed pattern to include reluctant quantifier "?" .

11 years ago

Campbell Ritchie wrote:Nice touch, using max and min rather than number literals. You do realise that formula will never produce 50 as a result, only 49?

Yes. And if you want to include 50 change the code to this..
int num = rand.nextInt(max-min+1) + min;
11 years ago
First generate a random number and then map it to your range. If you want between 10 and 50
Random rand = new Random();
int min=10,max=50;
int num = rand.nextInt(max-min) + min;

Hope this helps!
11 years ago
Hi all,
I am writing a program to delete all the comments from a given java file.

I was able to remove the single line comments using pattern - Pattern p= Pattern.compile("//(.)*");

But matching multiline comments is getting trickier.
I am using - Pattern p= Pattern.compile("/\\*.*\\*/", Pattern.DOTALL); - Basically match anything between /* and */ and include new lines.

But If I have something like below, it is matching this entire thing as a single match and I am losing the code between the comments.

Could some one help me how to rewrite this pattern so that I dont delete the code between the comments?

Thanks in advance.
11 years ago
Your class is already under the package - hsbookdemo and you already had that in the very first line of your class. so you don't need the second package.

And regarding your question to create new package in IDE just right click on your project name and select new package.

Hope this helps!
12 years ago
I know this is late.. but do you still have place for me on your team? If So let me know what I need to do to get started!

Thanks in advance!
12 years ago
That worked.. Thanks much!
12 years ago
Error is on line 30 where I format the obj...


12 years ago
I have a requirement of converting times in different time zones to PST.

example if I give "03:30 AM CST" my method should return time in PST.

but its throwing following error:

Exception in thread "main" java.lang.IllegalArgumentException: Cannot format given Object as a Date

Can some one tel me what is mistake? and is htere a better/elegant way of doing this?

Thanks in advance!
12 years ago
Paul, thanks for your reply... finally I figured the way to do it using OutputFormat object.

I kinda overlooked the documentation, thanks for pointing me to it.

I am creating an XML file that will be used on the mainframe machine. But I have some issues with the generated XML file.

I am using the DOM object and XMLWriter class to generate the file. I am using following code

But this generates an XML file that looks like below :

<?xml version="1.0" encoding="UTF-8"?>
<root><doc><info><docDescription> blah blah.... </root>

But I want to remove the encoding="UTF-8" attribute and want the entire XML without any spaces/new line characters like below...
<?xml version="1.0"?><root><doc><info><docDescription> blah blah.... </root>

Does Anyone know how to achieve this???

Thanks in advance.....

Thank you guys for your replies..
13 years ago