我有一個匹配方程正則表達式在分隔符後匹配並找到更高的匹配數?
function start() {
var str = "10x2+10x+10y100-20y30";
var match = str.match(/([a-z])=?(\d+)/g);//find the higher value of power only and also print the power value only withput alphapets).i need match like "100"
var text;
if(match < 10)
{text = "less 10";}
else if(match == "10")
{text == "equal";}
else
{text ="above 10";}
document.getElementById('demo').innerHTML=text;
}
start();
<p id="demo"></p>
我需要匹配的功率值,也失控,只有更高的功率值。
例如:10x2+10y90+9x91 out --> "90"
。 我的錯誤和糾正我的正則表達式匹配與合適的格式。謝謝
在我上面的代碼中更高的功率值'100'.but你r編碼出來是'30' – prasad
@prasad對不起,我忘了在'var line currentValue = parseInt(match [i] .substring(1))'''上使用parseInt();''。它已經被糾正了,現在起作用了。 –