/// <summary>
/// Query with dynamic Include
/// </summary>
/// <typeparam name="T">Entity</typeparam>
/// <param name="context">dbContext</param>
/// <param name="includeProperties">includeProperties with ; delimiters</param>
/// <returns>Constructed query with include properties</returns>
public static IQueryable<T> MyQueryWithDynamicInclude<T>(this DbContext context, string includeProperties)
where T : class
{
string[] includes = includeProperties.Split(';');
var query = context.Set<T>().AsQueryable();
foreach (string include in includes)
query = query.Include(include);
return query;
}
我希望匹配&#39; [M] +&#39;和&#39; [M] 2 +&#39;
但结果是
re.findall("\[M(\+\d)?\](\d)?\+", u'[2][M]+[2][M]2+')
答案 0 :(得分:-1)
您已在正则表达式模式中捕获了组,这使得findall
返回组;如果您需要返回匹配项,则可以使用?:
:
import re
re.findall("\[M(?:\+\d)?\](?:\d)?\+", u'[2][M]+[2][M]2+')
# ^^ ^^
# ['[M]+', '[M]2+']