Hi,

I think the (.*) is being greedy here... Instead of .*, try a pattern that
matches only alphabets,numbers and tabs.. or u can make it not to include
"<". Something like ([^<]*) would work I think...

Thanks
Arvind

On 11/3/07, chandu_mek <[EMAIL PROTECTED]> wrote:
>
>    Hi all,
>
> Please give me a regular expression to capture Product name (
> Apple ibook 12 ) from the following string.
>
> No</B></FONT><BR>Apple ibook 12<BR><FONT color=#ff0000><B>Processor
> </B></FONT><BR>1.33GHz PowerPC G4 <BR><FONT color=#ff0000><B>Level
> 2</B></FONT><BR>Cache 512K at 1.33GHz <BR><FONT
> color=#ff0000><B>System bus</B></FONT>
>
> I tried with .*No</B></FONT><BR>(.*)(<BR><FONTcolor=#ff0000><B>).*
> expression but it's giving the following out put.
>
> Apple ibook 12<BR><FONT color=#ff0000><B>Processor
> </B></FONT><BR>1.33GHz PowerPC G4 <BR><FONT color=#ff0000><B>Level
> 2</B></FONT><BR>Cache 512K at 1.33GHz
>
>
> Programm : SamplePatternMat.java
> ***************************************
>
> public class SamplePatternMat {
>
> private static String
> REGEXP=".*No</B></FONT><BR>(.*)(<BR><FONTcolor=#ff0000><B>).*";
>
> public static void main(String [] args) throws Exception{
>
>
>
> Pattern p=Pattern.compile(PRODUCT_NAME_REGEXP);
>
> String inputStr="No</B></FONT><BR>Apple ibook 12<BR><FONT
> color=#ff0000><B>Processor </B></FONT><BR>1.33GHz PowerPC G4 <BR><FONT
> color=#ff0000><B>Level 2</B></FONT><BR>Cache 512K at 1.33GHz <BR><FONT
> color=#ff0000><B>System bus</B></FONT>";
>
> Matcher m=p.matcher(inputStr);
>
> if(m.find())
> {
> System.out.println("Product Name : " + m.group(1));
> }
>
> }
>
> }
>
> Thanks in advance,
> chandrashekhar.

Reply via email to