如何删除字符串周围的{},如下所示? {636D9115-E54E-4673-B992-B51A8F8DDC8B}我只想返回以下内容:636D9115-E54E-4673-B992-B51A8F8DDC8B
答案 0 :(得分:3)
使用修剪:
"{636D9115-E54E-4673-B992-B51A8F8DDC8B}".trim('{}')
使用多个替换:
"{636D9115-E54E-4673-B992-B51A8F8DDC8B}".Replace('{','').Replace('}','')
将Reg替换为RegEx
"{636D9115-E54E-4673-B992-B51A8F8DDC8B}" -replace '\{(.*)\}','$1'
使用纯RegEx:
"{636D9115-E54E-4673-B992-B51A8F8DDC8B}" -match '\{(.*)\}'
$Matches[1]