标签: text-search

如何在cefSharp中实现文本搜索

我正在使用cefSharp. 现在我需要像Google Chromehas一样向用户提供文本搜索功能。任何人都可以帮助我在cefSharp.

text-search c#-4.0 cefsharp

3
推荐指数
2
解决办法
3446
查看次数

如何访问 Text Score MongoDB $text search

我成功地在 Node.js 代码中使用 Mongoose 运行 $text 搜索。这是我使用的代码:

Model.find( 
     { $text : { $search : "FindThisString"}},
     { score : {$meta : "textScore"}}
  )
 .sort({ score : { $meta : 'textScore'}})
 .exec(function(err, results) {
     _.each(results, function(item) {
        //console.log(item);
        console.log(item._id);
        console.log(item.score);
     });
});
Run Code Online (Sandbox Code Playgroud)

当我控制台记录整个文档时,我可以在控制台上看到“score”字段,但“item.score”打印为“undefined”。

如何在返回的结果中访问 MongoDB 创建的分数?

text-search mongoose mongodb node.js mongodb-query

2
推荐指数
1
解决办法
1165
查看次数

MongoDB:使用变量进行文本搜索(完全匹配)

MongoDB 3.4

我在一个变量中有一个值。val1 = "Fort Minor"

我需要在集合商店(名称字段上带有文本索引)中搜索文档为

db.stores.insert([
     { _id: 1, name: "Java Hut", description: "Coffee and cakes" },
     { _id: 2, name: "Burger Buns", description: "Gourmet hamburgers" },
     { _id: 3, name: "Coffee Shop", description: "Just coffee" },
     { _id: 4, name: "Fort Coffee", description: "Discount clothing" },
     { _id: 5, name: "Java Shopping", description: "Indonesian goods" }
])
Run Code Online (Sandbox Code Playgroud)


当我使用变量文本搜索集合时

db.City.find({$text:{$search: val1}})
Run Code Online (Sandbox Code Playgroud)

它返回 _id : 4 文档,因为它包含 Fort。

我需要做一个完全匹配但使用变量。

上面的搜索应该只在 val1 = "Fort Coffee" 时返回

text-search mongodb exact-match

2
推荐指数
2
解决办法
9801
查看次数

在 JS 中查找字符串中的关键字

我有一个输入字段,我希望用户在其中输入包含许多关键字之一的文本,这些关键字将根据关键字触发不同的音频文件。(我知道从 UX 的角度来看这不是很聪明,但这只是虚拟助手的模型/演示)。

我正在使用此代码,但我觉得我可以做得更好,您能提出一些替代方案吗?

    keyword1 = "music";
    keyword2 = "news";
    keyword3 = "weather";
    keyword4 = "cooking";
    keyword5 = "pasta";
    keyword6 = "tech";

    if(text.search(keyword1)!=-1) {
      audio.src = a_music;
      audio.play();
    } else if(text.search(keyword2)!=-1){
      audio.src = a_news;
      audio.play();
    } 
   [...]
  }
Run Code Online (Sandbox Code Playgroud)

javascript if-statement substring cycle text-search

2
推荐指数
1
解决办法
4619
查看次数

正则表达式仅查找第一个匹配项

我有这样的文字: -

SOME text, .....
Number of successes: 3556
Number of failures: 22
Some text, .....
Number of successes: 2623
Number of failure: 0
Run Code Online (Sandbox Code Playgroud)

我的要求是找到这种模式的第一次出现"成功次数:(\ d +)",这是成功次数:3556.但是上面的表达式也会返回后续匹配.

我希望正则表达式为我做这个,不像在java中我可以使用循环来迭代.

任何人都可以帮我一个只能找到第一次出现的正则表达式.

regex search text-search regex-greedy regex-lookarounds

1
推荐指数
1
解决办法
9793
查看次数

在<div>中搜索文本

我正在尝试在单个HTML5页面上搜索EACH,然后如果没有匹配项,则将其隐藏。我“差不多”了,但还不在那里。到目前为止,如果有单个字符的匹配项,我将消失,但是如果我键入其他任何内容,则将重新出现。另外,如果我清除搜索框,我想重置页面。如果您能看一下Java的话,我们将不胜感激。

function myFunction() {
    input = document.getElementById("Search");
    filter = input.value.toUpperCase();
    for (i=0; i<document.getElementsByClassName('target').length; i++){
if(document.getElementsByClassName('target'[i].innerHTML.toUpperCase().indexOf(filter) > -1) {     
    document.getElementsByClassName("target")[i].style.display = "none";
            }
        else{
        	document.getElementsByClassName("target")[i].style.display = "";
        } 
    }
}
    </script>
Run Code Online (Sandbox Code Playgroud)
    <table align="center" width="20%">
    <tr>
      <td style="padding-right: 10px">
        <input type="text" id="Search" onkeyup="myFunction()" 
        placeholder="Please enter a search term.." title="Type in a name">
      </td>
    </tr>
    </table>
    <br>


    <div class="target">
    This is my DIV element.
    </div>
    <div class="target">
    This is another Div element.
    </div>
Run Code Online (Sandbox Code Playgroud)

javascript jquery html5 text-search

1
推荐指数
1
解决办法
5781
查看次数

在批处理脚本中搜索文本文件中的字符串

如何逐行搜索文本文件中的字符串,并在找到匹配项时将找到匹配项的整行复制到变量中?

基本上,我有一个文本文件,其中包含文件夹中所有子文件夹的地址/路径。我想在这个文本文件中搜索一个字符串(该字符串将只匹配一行的一部分),如果有匹配项,我想将整行复制到一个变量中。

该字符串来自文件名,一旦文本文件中有匹配项,我想使用子文件夹地址将文件移动到那里。

这是我迄今为止所做的:

@ECHO off
::Reads all the folders and subfolders existing in the "root1" folder and   writes the path for each foleder/subfolder into the "1.txt" file
dir /b /s /a:d "...\root1" > "...\1.txt"

::Reads all the files existing in "root2" folder and writes the path of each file into the "2.txt" file
dir /s /b "...\root2\" > "...\2.txt"

SETLOCAL EnableDelayedExpansion

::reads the last file path from the "2.txt" and asign it to a variable
for /f "delims=" %%x …
Run Code Online (Sandbox Code Playgroud)

batch-file text-search string-search

0
推荐指数
1
解决办法
3万
查看次数