更新时间:2023-11-28 22:28:46
可以使用正则表达式匹配来测试:
You can use a regular expression match to test it:
if($substring -match "^\d+$")
{
# Do something
}
这应该适用于任何只包含数字的字符串(即正整数).如果要包含负整数,请将模式更改为 ^-?\d+$
.
This should work for any string which contains only digits (i.e. is a positive integer). Change the pattern to ^-?\d+$
if you want to include negative integers.