我需要用位置值替换下面的代码值。
string str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ;
DN = str.replaceAll( "Code" , LOCATION ) ;
我得到的方法签名不正确,因为字符串定义包含 "=" 和 "," 符号。有什么帮助吗?
谢谢。
string str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ;
看起来不对。“字符串”不是一个类。它必须是String
或def
。像下面
String str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ;
或者
def str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ;
无需设置错误的字符串,然后使用替换来使其正确。
只需使用模板来创建正确的字符串。IE:
String DN = "OU=Contractors,OU=Users,OU=$LOCATION,OU=Sites,DC=xyz,DC=com"