小编Col*_*ter的帖子

在powershell中替换时,正则表达式无效

$ 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

powershell powershell-3.0

3
推荐指数
2
解决办法
2万
查看次数

在Java中重用字符串

我一直想知道是否有任何方法可以重用字符串,如:

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,所以如果你有一个循环的用户输入,如果一个东西没有出现,它不会中断.

java user-input

0
推荐指数
1
解决办法
656
查看次数

标签 统计

java ×1

powershell ×1

powershell-3.0 ×1

user-input ×1