Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 返回不带尾随的字符串'/';性格_String_Url_Powershell - Fatal编程技术网

String 返回不带尾随的字符串'/';性格

String 返回不带尾随的字符串'/';性格,string,url,powershell,String,Url,Powershell,我在PowerShell错误检查变量的尾部斜杠并将其删除时遇到问题。例如: $example1 = 'https://mysite.com/siteone' $example2 = 'https://mysite.com/sitetwo/' 如何检查尾部斜杠?所以,如果我的脚本返回$example1,这很好,脚本将继续。但是,如果它返回$example2,则删除尾随斜杠并使其仅为: https://mysite.com/sitetwo 您可以使用以下命令修剪任何尾随的/字符: 您可以使用以下

我在PowerShell错误检查变量的尾部斜杠并将其删除时遇到问题。例如:

$example1 = 'https://mysite.com/siteone'
$example2 = 'https://mysite.com/sitetwo/'
如何检查尾部斜杠?所以,如果我的脚本返回
$example1
,这很好,脚本将继续。但是,如果它返回
$example2
,则删除尾随斜杠并使其仅为:

https://mysite.com/sitetwo

您可以使用以下命令修剪任何尾随的
/
字符:


您可以使用以下命令修剪任何尾随的
/
字符:

PS > $example1 = 'https://mysite.com/siteone'
PS > $example1.TrimEnd('/')
https://mysite.com/siteone
PS > $example2 = 'https://mysite.com/sitetwo/'
PS > $example2.TrimEnd('/')
https://mysite.com/sitetwo
PS >