File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Regular Expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regular Expression" Watch "Regular Expression" New topic
Author

Regular Expression

Vinod Awar
Ranch Hand

Joined: Nov 06, 2006
Posts: 125
Hello java guru's,

iam using regular expressions. I have a html file from which i want to grab some text. The file contents are something like this

now from this code i want to take out the first parameter of the SL constructor and store in a ArrayList. i used a pattern like

but with this i get all four lines(i.e new SL() lines). is there a method in regex which returns all matches separately.



The biggest bankruptcy is the loss of enthusiasm
Vinod Awar
Ranch Hand

Joined: Nov 06, 2006
Posts: 125
I tried by removing the DOTALL option but iam getting the constructors first parameter from the last line only.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18977
    
  40

By default a qualifier is greedy, so it will match the first "new SL('" all the way to the last "','". For what you will need, you will have to make the group 1 qualifier reluctant -- use (.*?) instead.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regular Expression