iT邦幫忙

0

Code Generation 6:利用JAVA將AS檔案轉成TS檔案型態-資料標準化

在轉檔時,標準化很重要,因為沒有標準,沒有辦法做出正常的取代功能。
例底下的4行程式,功能是想同的,但:
標準化的重要性,影響到轉檔能不能成功,在你要比對資料之前,一定要將某些程式碼做一個標準。
例:遇到event.stop=true;整段直接刪除

if (ArrayStr[i].indexOf("event.stop=true;") >= 0){
	ArrayStr[i]="";
}

但如果是以下四種狀況,要不要刪。

event.stop =true; 
event.stop = true; 
event.stop= true; 
event.stop=true; 

所以在比對資料之前我會先對程式做一些標準化

	str = str.replaceAll("	", "");		//tab取代為空字串
	str = str.replaceAll("\"", "'");    //這句是因為TS是用單引號,所以只要遇到雙引號,就全部換成單引號
	str = str.replaceAll(", ", ",");	//去除空白
	str = str.replaceAll(" ,", ",");	//去除空白
	str = str.replaceAll(" =", "=");	//去除空白
	str = str.replaceAll("= ", "=");	//去除空白
	str = str.replaceAll(" =", "=");	//去除空白
	str = str.replaceAll("= ", "=");	//去除空白
	str = str.replaceAll(": ", ":");	//去除空白
	str = str.replaceAll(" :", ":");	//去除空白


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言