Java: Trouver un String entre deux autres String

Author:

 int,string,char,static, url, socket, url, socket, java
Download

/**
 * @(#)ExempleStringBetween.java
 * Trouver un String entre deux autres String
 *
 * @author sakoba(mesexemples.com) 
 *sakoba(java.mesexemples.com) @version 1.00 2012/12/4
 */
 
import org.apache.commons.lang3.StringUtils;
 
public class ExempleStringBetween {
 
    public static void main (String[] args) 
    	{  
    		String codeHTML = "<html>\n" +
				" <head>\n" +
				" <title>Pages mesexemples.com</title>\n" +
				"<script type='javascript>'>"+
				" alert('welcom')</script>"+
				" </head>\n" +
				" <body>\n" +
				" <p>Exemple d'utilisation de Apache Common!</p>\n" +
				" </body>\n" +
				"</html>";
// Extraire le titre du contenu HTM
String titre = StringUtils.substringBetween(codeHTML, "<title>",
"</title>");
System.out.println( "Titre: " + titre );
// Extraire le Script du contenu HTM
String scripte = StringUtils.substringBetween(codeHTML, "<script type='javascript>'>",
"</script>");
System.out.println( "Scripte: " + scripte );
 
        } 
 
}

Cet article Java: Trouver un String entre deux autres String est apparu en premier sur .