// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m)public ([\w><]+ [\w><]+\(\))\s+{[^}]+}").unwrap();
let string = "using System.Linq;
using NineYi.ERPV2.DA.AppDB.Tables;
namespace NineYi.ERPV2.DA.Repositories.DbRepositories
{
/// <summary>
/// AppDbRepository
/// </summary>
public class AppDbRepository : IAppDbRepository
{
/// <summary>
/// AppDbContext
/// </summary>
private AppDbContext _appDbContext;
/// <summary>
/// Initializes a new instance of the <see cref=\"AppDbRepository\" /> class.
/// </summary>
/// <param name=\"appDbContext\">AppDbContext</param>
public AppDbRepository(AppDbContext appDbContext)
{
this._appDbContext = appDbContext;
}
/// <summary>
/// SaveChanges
/// </summary>
public void SaveChanges()
{
this._appDbContext.SaveChanges();
}
/// <summary>
/// QueryUserCoupons
/// </summary>
/// <returns>UserCoupons</returns>
public IQueryable<user_coupon> QueryUserCoupons()
{
return this._appDbContext.user_coupon;
}
/// <summary>
/// QueryPubContents
/// </summary>
/// <returns>PubContents</returns>
public IQueryable<pub_content> QueryPubContents()
{
return this._appDbContext.pub_content;
}
}
}";
let substitution = "\\1;";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/