正则表达式不匹配(用于url)

时间:2018-09-11 14:21:46

标签: c# .net regex

我们去

import pandas as pd
import matplotlib.pyplot as plt

ID = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Budget_1 = [1000, 1200, 1300, 100 ,500, 0, 800, 950, 4321, 800, 1000, 1200, 1300, 100 ,500, 0, 800, 950, 4321, 800]
Budget_2 = [1000, 1200, 1300, 100 ,500, 0, 800, 950, 4321, 800, 1000, 1200, 1300, 100 ,500, 0, 800, 950, 4321, 800]
Budget_3 = [1000, 1200, 1300, 100 ,500, 0, 800, 950, 4321, 800, 1000, 1200, 1300, 100 ,500, 0, 800, 950, 4321, 800]
FY = [2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2019]
Days = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]
spend = [2.5, 3.0, 4.0, 5.0, 4.0, 10.0, 2.5, 2.0, 4.0, 2.5, 2.5, 3.0, 4.0, 5.0, 4.0, 10.0, 2.5, 2.0, 4.0, 2.5]
Spent_1 = ''
Spent_2 = ''
Spent_3 = ''
Total_Spent = ''
d = {'ID': ID, 'Budget 1': Budget_1, 'Budget 2': Budget_2, 'Budget 3': Budget_3, 'Fiscal Year': FY, 'Days': Days, 'Spent 1': Spent_1, 'Spent 2': Spent_2, 'Spent 3': Spent_3, 'Total Spent': Total_Spent, 'Spend Rate': spend}
df = pd.DataFrame(d)

print(df)

df = df.sort_values(['Fiscal Year', 'ID'], ascending = True)

def funded_calc(spendrate):
    spent1 = spendrate*df['Days']
    df['Spent 1'] = df['Spent 1'] - spent1
    return spent1

df['Spent'] = df['Spend Rate'].apply(funded_calc)

print(df)

logResult为private static readonly string _regexPattern = @"[/]api[/]v[0-9].[0-9][/]Subscriber[/][0-9]{10}"; public override string GenerateRowKey(LogEvent logEvent, string suffix = null) { var logResult = $"{logEvent.Properties["RequestPath"]}"; var regex = new Regex(logResult); var fh = regex.IsMatch(_regexPattern); --- }

不知道为什么这行不通。

1 个答案:

答案 0 :(得分:3)

您以错误的顺序传递了模式/文本时,ctor想要一个模式,以便以后使用Eric进行测试:

IsMatch()

还有一个static IsMatch()可以减少键入和使用内部缓存。