我试图显示输入的搜索词的最佳匹配.例如
现在Jquery没有给我预期的效果.当我输入:今天一个自动完成将显示任何内容,但如果我键入一天,它将显示以该顺序中的这两个单词开头的搜索结果.我想今天出现的一天是今天的第一天和最后一天.我希望搜索结果显示在其中包含这些单词的顺序并不重要.我在这里看了一下,却找不到这样的东西,这似乎是一种常见的搜索方法,我看不出为什么没有人问过这个问题.是否有一个内置的方法来处理这个?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
var availableTags = [
"one day is the first and last today" , "tuesday is today" , "one" , "one day is tomorrow"
];
$( "#tags" ).autocomplete({
source: availableTags, multiple: true,
mustMatch: false
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label …Run Code Online (Sandbox Code Playgroud) 在下面的代码中,getreport是一个由/t和格式化的文本项/n.我正在尝试输出一个电话号码列表,但返回的列表会像这样返回:['5','5','5','7','8','7', ...]等等,而不是类似['5557877777']的内容.这有什么不对?
def parsereport(getreport):
listoutput = []
lines = re.findall(r'.+?\n' , getreport) #everything is in perfect lines
for m in lines:
line = m
linesplit = line.split('\t') # Now I have a list of elements for each line
phone = linesplit[0] # first element is always the phone number ex '5557777878'
if is_number(linesplit[10]) == True:
num = int(linesplit[10])
if num > 0:
listoutput.extend(phone)
Run Code Online (Sandbox Code Playgroud)
我尝试将print(手机)进行测试,它看起来很棒,并返回'5557877777'等行,但返回列表= ['5','5'等]并且数字被拆开.
return listoutput
Run Code Online (Sandbox Code Playgroud)