I am using java....
.MainNav a:hover{ float:left; width:70px; height:65px; border-top: 2px Solid #F4E6CC; border-bottom: 2px Solid #805822; border-left: 2px Solid #F4E6CC; border-right: 2px Solid #805822; margin: 0px 0px 0px 0px; align:center; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; color: #FFFFFF; text-decoration: none; text-align: center; background:#C99349; background-image: url(../../images/hor_nav_bg.gif); background-repeat: repeat-X; padding:4px; clear:left; }
above is css class i want regular expression such that group contains values like
group1 = MainNav a:hover
group2 = { float:left; width:70px; height:65px; border-top: 2px Solid #F4E6CC; border-bottom: 2px Solid #805822; border-left: 2px Solid #F4E6CC; border-right: 2px Solid #805822; margin: 0px 0px 0px 0px; align:center; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; color: #FFFFFF; text-decoration: none; text-align: center; background:#C99349; background-image: url(../../images/hor_nav_bg.gif); background-repeat: repeat-X; padding:4px; clear:left; }
means class name and other is definition can you please tell me the regular expression for that? I am little bit confuse how to create expression for that so that I can get the output.
Here is my code for
package com.tufan.digite.Count;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GetAllCssFile {
public static void main(String args[]) throws IOException {
try {
FileInputStream fstream = new FileInputStream("D:/digite/work/digite/WEBUI/common/theme1/common.css"); // Get theobject of DataInputStream
DataInputStream dis = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(dis));
String strLine;
while ((strLine = br.readLine()) != null) {
Matcher matcher = Pattern.compile("([^}]^)({[^}]+})", Pattern.DOTALL | Pattern.MULTILINE).matcher(strLine);
if (matcher.find()) {
String selector = matcher.group(1);
String definition = matcher.group(2);
System.out.println("selector:" + selector + "definition:"+definition);
}
}
} catch (Exception e) {
//Do some exception handling here
}
}
}
it will not give any answers