我将如何做这样的事情:
if(richTextBox1.Text.Contains("what"){
int line = //get the line that this text is on
string value = //read the text on value
}
答案 0 :(得分:1)
你在找这个:
foreach(string line in richTextBox1.Lines)
{
if(line.Contains("MY_STRING"))
{
//my logic
// the variable line is a string containing the your entire text in that line
}
}
答案 1 :(得分:0)
使用正则表达式,无论文本来源如何,都可以执行此操作:
def find(l, match, v, k):
return next((x[k] for x in l if x[match] == v), None)
results = []
for ip_info in list1:
ip = ip_info['IP']
_id = ip_info['ID']
vul = find(list2, 'ID', _id, 'vulnerability_id')
desc = find(list3, 'vulnerability_id', vulnerability, 'description')
results.append(dict(ip=ip, vulnerability=vul, description=desc))