myRe = re.compile(r"(myFunc\(.+?\,.+?\,)(.+?)(\,.+?\,.+?\,.+?\,.+?\))")
print myRe.sub(r'\1"noversion"\3', val)
Showing posts with label regex. Show all posts
Showing posts with label regex. Show all posts
Tuesday, February 7, 2012
Python regex replace part of matched string
Wednesday, November 23, 2011
Get regex matched strings (Regex Capture) C#
Program that uses Match [C#]
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
// A
// The input string we are using
string input = "OneTwoThree";
// B
// The regular expression we use to match
Regex r1 = new Regex(@"One([A-Za-z0-9\-]+)Three");
// C
// Match the input and write results
Match match = r1.Match(input);
if (match.Success)
{
string v = match.Groups[1].Value;
Console.WriteLine("Between One and Three: {0}",
v);
}
}
}
Output
Between One and Three: Two
Subscribe to:
Posts (Atom)