« Return to Thread: How to use variables inside regular expressions in Jython ?

Re: How to use variables inside regular expressions in Jython ?

by Anthony Smith-11 :: Rate this Message:

Reply to Author | View in Thread

Hi Ranga,

On 5 Jun 2009, at 01:18, Ranga Raju C.V.S. wrote:

> 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.


Try
expr = ".*" + nodeName + ".*"

 >>> expr = ".*" + nodeName + ".*"
 >>> pat4 = re.compile(expr)
 >>> m = re.search(expr, oNodes)
 >>> m.group()
'wsejbfpp1wpdiu528(cells/WS16/nodes/wsejbfpp1wpdiu528|node.xml#Node_1)'

Cheers,

Anthony

------------------------------------------------------------------------------
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

 « Return to Thread: How to use variables inside regular expressions in Jython ?