如果我只知道字符串的一部分,如何在文本文件中找到字符串?例如,我只知道".someserver.com"
但文件中的整个文本如下所示:
"hostname1.expedite.someserver.com"
所以关键是要通过只知道一部分来找到整个名字
部分文件内容:
{"attributes": {"meta_data": {"created_at":1614882362.179626, "created_by": "admin"}, "site": "AF002"}, hostname:"hostname1.expedite.someserver.com",
假设您的源文件是一个包含大量主机名的sample.txt文件,最简单的方法是使用regex“hostname.someserver.com”,其中通配符()在hostname和someserver.com示例之前
假设您的数据如下所示:
我们可以:
这印着我们:
假设数据如下所示:
然后我们可以:
这给了我们:
相关问题 更多 >
编程相关推荐