public class getStyle {
public static void main(String[] args) throws FileNotFoundException {
try {
getStyle.handler();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (UnsupportedFlavorException e) {
throw new RuntimeException(e);
}
}
public static void handler() throws IOException, UnsupportedFlavorException {
String str = get().replaceAll("\\n|\\s","");
Matcher m = Pattern.compile("(?<=style=(\"|'))[a-zA-Z0-9;:\\.-]*",Pattern.MULTILINE).matcher(str);
while (m.find()){
System.out.println("\""+m.group()+"\",");
}
}
static Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
public static String get() throws UnsupportedFlavorException, IOException {
Transferable content = clipboard.getContents(null);
if (content.isDataFlavorSupported(DataFlavor.stringFlavor)) {
String text = (String) content.getTransferData(DataFlavor.stringFlavor);
return text;
}
System.out.println("error!");
System.exit(0);
return null;
}
}
标签:styles,String,RuntimeException,handler,获取,html,static,public,UnsupportedFlavorEx
From: https://www.cnblogs.com/laremehpe/p/17364223.html