Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.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
Python Jython如何删除字符串中的字符_Python_Regex_Websphere_Jython_Wsadmin - Fatal编程技术网

Python Jython如何删除字符串中的字符

Python Jython如何删除字符串中的字符,python,regex,websphere,jython,wsadmin,Python,Regex,Websphere,Jython,Wsadmin,这是一个与WebSphere相关的问题 我正在尝试将此命令转换为变量 AdminConfig.modify('(cells/taspmociias204Cell01/clusters/cam_group|resources.xml#J2EEResourceProperty_1324400045826)' 我发现这个命令: AdminConfig.list('J2EEResourceProperty', 'URL*cam_group*)').splitlines() 将返回: ['URL(ce

这是一个与WebSphere相关的问题

我正在尝试将此命令转换为变量

AdminConfig.modify('(cells/taspmociias204Cell01/clusters/cam_group|resources.xml#J2EEResourceProperty_1324400045826)'
我发现这个命令:

AdminConfig.list('J2EEResourceProperty', 'URL*cam_group*)').splitlines()
将返回:

['URL(cells/taspmociias204Cell01/clusters/cam_group|resources.xml#J2EEResourceProperty_1324400045826)', 'URL(cells/taspmociias204Cell01/clusters/cam_group|resources.xml#J2EEResourceProperty_1355156316906)']
所以我把这个命令变成了一个变量:

j2ee = AdminConfig.list('J2EEResourceProperty', 'URL*cam_group*)').splitlines()
我可以通过键入“j2ee[0]”获得所需的字符串


这正是我想要的,减去前面的URL部分。我怎么才能摆脱那些角色

我不确定是否理解您的需求,但在我看来,您似乎想要修改J2EEResourceProperty对象的一些属性

如果是这种情况,那么您不需要删除“URL”字符串,实际上您不应该这样做。字符串
'URL(cells/taspmocias204cell01/clusters/cam|u group | resources.xml#J2EEResourceProperty_1324400045826)
完全标识WebSphere配置对象。试试这个:

AdminConfig.modify('URL(cells/taspmociias204Cell01/clusters/cam_group|resources.xml#J2EEResourceProperty_1324400045826)', [['value', 'the new value'], ['description', 'the new description']])
顺便说一句:您也可以尝试使用WDR库()。那么您的脚本将如下所示:

prop = listConfigObjects('J2EEResourceProperty')[0]
prop.value = 'the new value'
prop.description = 'the new description'

披露:我是WDR贡献者之一。

您可以始终使用一个简单的替换正则表达式来解析URL部分

例如:

import re
mystr = 'URL(blahblahblah)'
re.sub(r'^URL', "", mystr)
这是一个学习和测试正则表达式以确保其正确性的便捷工具。

我尝试将以下内容添加到搜索“m=re.search(”?
import re
mystr = 'URL(blahblahblah)'
re.sub(r'^URL', "", mystr)