单词语音音标正则式查询分析JavaScript应用

前端之家收集整理的这篇文章主要介绍了单词语音音标正则式查询分析JavaScript应用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

可以使用正则表达式查询音标

<!DOCTYPE html>
<html>
<head>
<Meta charset="utf-8">
<Meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<title>phonetics</title>
<style type="text/css">
body{
	background-color:#CCCCCC;
	padding:50px;
	font-family:IPAPANNEW;
}
button{
	margin:5px;
}
</style>
<script type="text/javascript" src="pronunciation.js"></script>
<script type="text/javascript">
function $(id){
	return document.getElementById(id);
}
function search(){
	var regString=$("regString").value;
	var reg=new RegExp(regString,"ig");
	var resultArray=new Array();
	for(var word in phonetics){
		var pronunciation=phonetics[word];
		var pass=reg.test(pronunciation);
		if(pass){
			resultArray.push(word+" : "+pronunciation);
		}
	}
	
	var resultCount=resultArray.length;
	$("resultDiv").innerHTML="找到匹配单词"+resultCount+"个"+"<hr>"+resultArray.join("<br/>").replace(/\$/g,"");
	
	


}
</script>
</head>

<body>
<input id="regString" type="text" placeholder="在此输入音标正则表达式查询对应单词" onkeypress="if(event.keyCode==13){search()}" value="" />
<button onclick="search()">search</button>
<button onclick="$('regString').value=''">clear</button>

<br/><br/>

<button onclick="$('regString').value+=this.innerHTML">iː</button>
<button onclick="$('regString').value+=this.innerHTML">i</button>
<button onclick="$('regString').value+=this.innerHTML">ɪ</button>
<button onclick="$('regString').value+=this.innerHTML">e</button>
<button onclick="$('regString').value+=this.innerHTML">æ</button>
<button onclick="$('regString').value+=this.innerHTML">ɑː</button>
<button onclick="$('regString').value+=this.innerHTML">ɒ</button>
<button onclick="$('regString').value+=this.innerHTML">ɔː</button>
<button onclick="$('regString').value+=this.innerHTML">ʊ</button>
<button onclick="$('regString').value+=this.innerHTML">u</button>
<button onclick="$('regString').value+=this.innerHTML">uː</button>
<button onclick="$('regString').value+=this.innerHTML">ʌ</button>
<button onclick="$('regString').value+=this.innerHTML">ɜː</button>
<button onclick="$('regString').value+=this.innerHTML">ə</button>
<button onclick="$('regString').value+=this.innerHTML">əː</button>

<br/>

<button onclick="$('regString').value+=this.innerHTML">eɪ</button>
<button onclick="$('regString').value+=this.innerHTML">əʊ</button>
<button onclick="$('regString').value+=this.innerHTML">oʊ</button>
<button onclick="$('regString').value+=this.innerHTML">aɪ</button>
<button onclick="$('regString').value+=this.innerHTML">ɔɪ</button>
<button onclick="$('regString').value+=this.innerHTML">aʊ</button>
<button onclick="$('regString').value+=this.innerHTML">ɪə</button>
<button onclick="$('regString').value+=this.innerHTML">eə</button>
<button onclick="$('regString').value+=this.innerHTML">ʊə</button>

<button onclick="$('regString').value+=this.innerHTML">[</button>
<button onclick="$('regString').value+=this.innerHTML">^</button>
<button onclick="$('regString').value+=this.innerHTML">]</button>
<button onclick="$('regString').value+=this.innerHTML">ː</button>


<br/><br/>

<button onclick="$('regString').value+=this.innerHTML">p</button>
<button onclick="$('regString').value+=this.innerHTML">b</button>
<button onclick="$('regString').value+=this.innerHTML">t</button>
<button onclick="$('regString').value+=this.innerHTML">d</button>
<button onclick="$('regString').value+=this.innerHTML">k</button>
<button onclick="$('regString').value+=this.innerHTML">g</button>
<button onclick="$('regString').value+=this.innerHTML">tʃ</button>
<button onclick="$('regString').value+=this.innerHTML">dʒ</button>
<button onclick="$('regString').value+=this.innerHTML">f</button>
<button onclick="$('regString').value+=this.innerHTML">v</button>
<button onclick="$('regString').value+=this.innerHTML">θ</button>
<button onclick="$('regString').value+=this.innerHTML">ð</button>

<br/>

<button onclick="$('regString').value+=this.innerHTML">s</button>
<button onclick="$('regString').value+=this.innerHTML">z</button>
<button onclick="$('regString').value+=this.innerHTML">ʃ</button>
<button onclick="$('regString').value+=this.innerHTML">ʒ</button>
<button onclick="$('regString').value+=this.innerHTML">h</button>
<button onclick="$('regString').value+=this.innerHTML">m</button>
<button onclick="$('regString').value+=this.innerHTML">n</button>
<button onclick="$('regString').value+=this.innerHTML">ŋ</button>
<button onclick="$('regString').value+=this.innerHTML">l</button>
<button onclick="$('regString').value+=this.innerHTML">r</button>
<button onclick="$('regString').value+=this.innerHTML">j</button>
<button onclick="$('regString').value+=this.innerHTML">w</button>

<br/><br/>

<div id="resultDiv"></div>

</body>
</html>
原文链接:/regex/359054.html

猜你在找的正则表达式相关文章