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 back
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
eplace = "for(" + pattern +
subStrPattern1_hasInitialization + ";" + subStrPattern2_hasRestTillEnd
fNew.write( regObj.sub( strToFind, strToReplace ) )
else:
fNew.write( l)
}
Here problem is , i am not getting backreferences using \1 and \2
The strin
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
I have something like below in perl and i am searching for equivalent
in python:
::: 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 < 1
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
>
ith 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 there something
> &
"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
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 \
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 there something
else i have to
14 matches
Mail list logo