$ 100 ="$ env:APPDATA/somthing"
$ iamhere ="C:/ example"
$ 100 = $ 100 -replace"`$ env:APPDATA\somthing","$ iamhere"
我希望100美元替换为其内容的$ iamhere(以文本形式),虽然我收到此错误.
正则表达式模式无效:$ env:APPDATA\somthing.
在行:1个字符:1
$ 100 = $ 100 -replace"`$ env:APPDATA\somthing","$ iamhere"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo:InvalidOperation:($ env:APPDATA\somthing:String)[],RuntimeException
- FullyQualifiedErrorId:InvalidRegularExpression
我想这是因为我试图用目录替换一些文本,但我希望$ iamhere变量内的文本谢谢,CollinScripter
我一直想知道是否有任何方法可以重用字符串,如:
import java.io.Console;
public class input {
public static void main (String[] args) {
Console console = System.console();
String input = console.readLine("Type username: "); //user input
// name code
// clear string
String input = console.readLine("Hello, what would you like to do: ");
// other code
}
}
Run Code Online (Sandbox Code Playgroud)
通过清除字符串//clear string,所以如果你有一个循环的用户输入,如果一个东西没有出现,它不会中断.