有人可以幫助我如何實現以下模式作爲正則表達式?(x,y)數的簡單正則表達式
apple(x,y);
凡
0 <= x,y <= 100
那麼有效的結果將包括以下內容:
apple(0,0);
apple(0,10);
apple(77,12);
apple(100,0);
apple(100,100);
我希望有人能幫助我。 非常感謝
有人可以幫助我如何實現以下模式作爲正則表達式?(x,y)數的簡單正則表達式
apple(x,y);
凡
0 <= x,y <= 100
那麼有效的結果將包括以下內容:
apple(0,0);
apple(0,10);
apple(77,12);
apple(100,0);
apple(100,100);
我希望有人能幫助我。 非常感謝
使用數字範圍工具我得到類似這樣的東西
apple\(0*(\d|[1-9]\d|100),0*(\d|[1-9]\d|100)\);
apple
\(
0*
( # (1 start)
\d
| [1-9] \d
| 100
) # (1 end)
,
0*
( # (2 start)
\d
| [1-9] \d
| 100
) # (2 end)
\);
可以使用字符類指定你的電話號碼和量詞{}
的範圍限制重複:
apple\([0-9]+,(?:[0-9]{1,2}|100)\);
您是不是指'0 <= x' _and_'y <= 100'的C感?它寫得更好,寫成'x> = 0,y <= 100',還是你想的其他東西? – sln
0 <= x <= 100和0 <= y <= 100 – vihkat
那麼,剛剛刪除我的帖子然後。一定要使用有用的東西。截至目前,Kasramvd的答案並不完全正確。 – sln