Hi,
I am trying to use variable in regular expressions but its not working for some reason.
I am using Jython that comes with WebSphere 6.1.
wsadmin>print oNodes
ndm-ws16a(cells/WS16/nodes/ndm-ws16a|node.xml#Node_1)
wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)
wsadmin>
wsadmin>print oNodeList
['ndm-ws16a(cells/WS16/nodes/ndm-ws16a|node.xml#Node_1)', 'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)']
wsadmin>
wsadmin>print nodeName
wpdiu528
wsadmin>
wsadmin>expr = r".*wpdiu528.*"
wsadmin>pat4 = re.compile(expr)
wsadmin>m = re.search(expr,oNodes)
This 'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)' is the desired result. I am able to achieve this result when I provide "wpdiu528" directly in variable expr. But I would like to use another variable called nodeName in place of the string "wpdiu528" inside the regular expression.
I tried as shown below, but it fails.
wsadmin>expr = r".*%nodeName.*"
wsadmin>pat4 = re.compile(expr)
wsadmin>m = re.search(expr,oNodes)
wsadmin>print m
None
wsadmin>
wsadmin>m.group()
WASX7015E: Exception running command: "m.group()"; exception information:
com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "<input>", line 1, in ?
AttributeError: 'None' object has no attribute 'group'
wsadmin>
Please see if you can assist me here...
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to:
http://p.sf.net/sfu/opensolaris-get_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users