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