Pankaj <[EMAIL PROTECTED]> wrote:
>search for :for ( i = 0; i < 10; i++)
>Replace with: for( printf( "10" ), i =0; i < 10; i++)
>Where 10 is the line no.
>f = open( "./1.c", "r")
>fNew = open( "./1_new.c", "w")
>for l in f:
>print l
>lineno = lineno + 1
>strToFind = "f
Pankaj wrote:
Perl :::
> ***
> while( )
> {
>
> line = $_;
>
> pattern = "printf\( \"$lineNo \" \),";
>
> line =~ s/"for(.*)\((*.)\;(.*)/for$1\($pattern$2\;$3/g;
> }
>
> This is used to
>
> search for :for ( i = 0; i < 10; i++)
> Replace with: for( printf( "10" ),
"Pankaj" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> I have something like below in perl and i am searching for equivalent
> in python:
>
> ::: Perl :::
> ***
> while( )
> {
>
> line = $_;
>
> pattern = "printf\( \"$lineNo \" \),";
>
> line =~ s/"for(.*)
Pankaj wrote:
> Here problem is , i am not getting backreferences using \1 and \2
>
You wrote:
> subStrPattern1_hasInitialization = "\1"
"\1" is the way to create a string containing a control-A character. What
you actually wanted was a string containing a backslash and a "1", so you
need e
I got my answer
if ( m != None ) :
subStrPattern1_hasInitialization = m.group(1)
subStrPattern2_hasRestTillEnd = m.group(2)
str = subStrPattern1_hasInitialization +
subStrPattern2_hasRestTillEnd
strToReplace = "for(" + pattern + str
This gave me my soluti
My tries have with re have not yielded results::
{
strToFind = 'for*;*'
## Converting int to string, i.e. line no. to string
lineNoClone = lineno
pattern = "printf(\"" + str( lineNoClone) + "\"),"
regObj = re.compile( strToFind)
m = regObj.searc
Pankaj wrote:
> [...]
>
> What i tried in python was::
>
>
> f = open( "./1.c", "r")
> fNew = open( "./1_new.c", "w")
> for l in f:
> print l
> lineno = lineno + 1
> strToFind = "for\((.*)\;(.
On 23 Jan 2006 07:18:13 -0800, Pankaj <[EMAIL PROTECTED]> wrote:
>
> [snip]
>What i tried in python was::
>
>f = open( "./1.c", "r")
>fNew = open( "./1_new.c", "w")
>for l in f:
>print l
>lineno = lineno + 1
>strToFind = "for\((.*)\;(.*)"
>
>## For Converting int to
Iain King wrote:
>Amy Dillavou wrote:
>
>
>>Can someone help me with understanding how python uses backreferences?
>>I need to remember the item that was last matched by the re engine but i
>>cant seem to understand anything that I find on backreferences. if I
>>want to access the last match do
George and Iain -
Thanks for your help!!! It worked for me, and that book seems to be
really useful =)
A.D
On Wed, 2005-09-28 at 11:16 -0400, George Sakkis wrote:
> "Amy Dillavou" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Can someone help me with understanding how python u
"Amy Dillavou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Can someone help me with understanding how python uses backreferences?
> I need to remember the item that was last matched by the re engine but i
> cant seem to understand anything that I find on backreferences. if I
> w
Amy Dillavou wrote:
> Can someone help me with understanding how python uses backreferences?
> I need to remember the item that was last matched by the re engine but i
> cant seem to understand anything that I find on backreferences. if I
> want to access the last match do i use \number or is the
12 matches
Mail list logo