简体   繁体   English

T-SQL搜索html与正则表达式?

[英]T-SQL search html with regex?

In my database I have a field wich contains a html document. 在我的数据库中,我有一个包含html文档的字段。 Now there must be a possibility to search in this document. 现在必须有可能在这个文件中搜索。 However, the html tags may not be found. 但是,可能找不到html标记。 So when I have something like this: 所以,当我有这样的事情时:

<html>
  <head>
    <title>Bar</title>
  </head>
  <body>
   <p>
     this content my be found
   </p>
  </body>
</html>

It is possible that the document stored in the database is not xhtml. 存储在数据库中的文档可能不是xhtml。 Can you tell me what the best way is to search in the content? 你能告诉我搜索内容的最佳方法是什么吗? Shall i use regular expressions? 我应该使用正则表达式吗? And of so, how would it look like? 那么,它会是什么样子? ANd if not, what should I use else? 如果不是,我还应该使用其他什么?

您可以尝试启用全文搜索或使用Lucene.Net之类的内容为您索引内容。

What volume of records are there? 有多少记录? I expect you might have to use full-text search and an IFilter to do this efficiently. 我希望您可能必须使用全文搜索和IFilter来有效地执行此操作。 Html does not lend itself well to regex - it can quickly be very hard to do something very simple. Html不适合正则表达式 - 很快就很难做一些非常简单的事情。

If the volume isn't huge, can you iterate over the records with an external parsing application, using something like the HTML Agility Pack (for .NET) - or any other DOM of your choice. 如果卷不是很大,你可以使用外部解析应用程序迭代记录,使用HTML Agility Pack(用于.NET)或任何其他您选择的DOM。

But the FTS/IFilter would be my first choice. 但FTS / IFilter将是我的首选。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM