我想在课堂上得到像...
<div class="main demo id_111 test"></div>
<div class="main demo test id_222 test demo"></div>
<div class="id_3 main demo test test demo"></div>
Run Code Online (Sandbox Code Playgroud)
结果必须是111,222和3
所以我这样编码
var id = $(".main").attr("class");
var id = id.split("id_");
var id = id[1].split(" ");
var id = id[0];
$("body").append(id);
Run Code Online (Sandbox Code Playgroud)
但有人知道编码比我的更好吗?
游乐场: http ://jsfiddle.net/UHyaD/
好的,所以我有一个LinkedList,我有一个字符串.我想检查String是否包含在任何LinkedList元素中.例如:
String a = "apple";
String listelement = "a bunch of apples";
LinkedList list = new LinkedList();
list.add(listelement);
if(list.containsany(a){
System.out.println("Hooray!");
}
Run Code Online (Sandbox Code Playgroud)
会导致印刷"万岁!"
显然list.containsany不是一个真正的LinkedList方法,我只是用它来实现这个目的.
那么我该如何模拟我的例子呢?
谢谢
我在使用这段linux代码时遇到了麻烦:
FILE=$(wget 'https://dl.dropbox.com/s/ru72h4b984qpxxq/spotify.txt' -q -O -)
if [ "$FILE" == "| |" ]
then
echo "File is a match"
Run Code Online (Sandbox Code Playgroud)
我不能说这个说法是真的.您是否介意检查网址的内容并告诉我,我是否对垂直线条或间距做错了?谢谢你的帮助.
我试着计算句子里有多少字母"a":"Hello Jordania".
我发现该功能包含.我这样使用它:
var phrase = "Hello Jordania;
var comptenbrdea = phrase.contains('a');
print(comptenbrdea);
Run Code Online (Sandbox Code Playgroud)
我得到"真实"作为回应.正常你会说,我知道,但我没有找到合适的功能来计算我得到一个多少时间.如果我可以检查每一个字符,我可以用循环做一些事情吗?...我迷失在http://www.dartlang.org/search.html?cx=011220921317074318178%3Ai4mscbaxtru&ie=UTF-8&hl=en&q=string_scanner ......有人可以帮助我吗?
将文件上传到表单时遇到问题.基本上,我想检查会话是否包含先前在form.cfm中提交的文件.但是,遇到的问题:复杂对象类型无法转换为简单值.这些是我的代码:
form.cfm代码::
<cfif structKeyExists(form, "Submit")>
<cfif isDefined("Form.filecontent") AND evaluate("Form.filecontent") NEQ "" >
<cffile action = "upload"
fileField = "file"
destination = "#GetTempDirectory()#"
nameConflict = "overwrite">
<cfset form.storage = cffile>
<cfelse>
<cfset form.storage = "">
</cfif>
<cfset session.checkout.input = {
storage=form.storage
}>
<cflocation url="formcomplete.cfm" addToken="false">
</cfif>
<!DOCTYPE html>
<html>
<head>
<title>Testing</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css" />
<!-- Other Scripts or CSS... -->
</head>
<body>
<form method="post" enctype="multipart/form-data">
<cfoutput>
<input id="filecontent" name="filecontent" class="input-file" type="file" accept="application/vnd.ms-excel">
</cfoutput>
<button …Run Code Online (Sandbox Code Playgroud) 检查下面是否有更好的解释 我在一个逐行读取的文件中有一长串项目,我想要对其中包含特定字符串的所有项进行排序.如果单词不包含sort中的任何元素,则它将被添加到字典中.我怎么做?我已经阅读了本网站上的其他一些情况,但我只是不明白......所以这可能是重复的,但我需要有人来解释我如何做到这一点.(是的项目来自游戏TF2)
item_list = ("Non-Tradable Ubersaw", "Screamin' Eagle", "'Non-Craftable Spy-cicle"
sort = ("Non-Tradable", "Non-Craftable") # The items that are not allowed
for word in item_list:
if not sort in word:
if word in items: # add to the dictionary
items[word] += 1
else:
items[word] = 1
Run Code Online (Sandbox Code Playgroud)
已经得到了答案,但只是为了澄清问题.我想运行sort list:item_list,我想通过创建一个数组来实现:sort,这样它会检查item_list中的每个元素,并检查该元素是否包含sort中的任何元素.如果没有,则将元素添加到字典中.
我试图检查数组列表是否包含反向顺序的数组,如果没有,添加它们:
var faclist = new List<int[]>();
var factors = new int[2] {i, j};
if (!faclist.Contains(factors.Reverse()))
{
faclist.Add(factors);
}
Run Code Online (Sandbox Code Playgroud)
但是,即使存在具有相反因素的数组,此代码也始终不正确.
使用CakePHP 1.3,我有一个Find语句,其条件为第3级深度关联:Hotel> Room> RoomType> name
我希望我的Find语句只返回具有名称"Suite"的RoomTypes的酒店.
我相信以下代码应该可以工作,但它没有,说明SQL语法错误:
$this->Hotel->find('first', array(
'contain' => array('Room' => array('RoomType')),
'conditions' => array(
'Hotel.Room.RoomType.name' => 'Suite'
),
));
Run Code Online (Sandbox Code Playgroud)
请注意,酒店将拥有许多客房,但每间客房仅提供1种RoomType
我已阅读有关在contains语句中使用条件的信息,但这仅限制返回的RoomTypes,而不是整个Hotels.
我在这里发布了类似的问题,但我还没有找到一个似乎可以解决这个问题的问题.
我创建了一个计算器,该计算器具有带数字的按钮和用于基本操作(+,-,...)的运算符,只想过滤带数字的按钮以检测单击数字的时间(介于0到9之间)。我也把新的eventhadler转换成按钮发送者。
我想知道什么是用数字过滤按钮的好方法(使用linq),到目前为止我尝试了什么
if(btn.Text == btn.Text.Contains(x => x >= '0' && x <= '9'))
MessageBox.Show("number " + btn.Text + " is pressed!");
Run Code Online (Sandbox Code Playgroud)
如何使上层代码可行?
在我的程序中,我有一个文本,我将分成一行数组来分别修改行.对于一个修改,我需要找到文本中值的最后一个索引,以在下面的行中插入一个新值.
例:
text=["I like bananas",
"I like apples",
"I like cherries",
"I like bananas",
"I like apples"]
value: "bananas"
Run Code Online (Sandbox Code Playgroud)
我已经尝试过使用:
int pos = Array.FindIndex(text, row => row.Contains(value));
if (pos > -1)
{
//insert line at pos
}
Run Code Online (Sandbox Code Playgroud)
但这似乎又回到了我第一次出现的指数."lastIndexOf()"对我来说似乎不是正确的命令,因为它会查找给定值和数组中项目的相等性.
我是做错了还是有另一个命令,在这种情况下使用?
如何检查变量是否出现在数组中?
在例子中
var X = 5;
var newArray = [1,2,5]
Run Code Online (Sandbox Code Playgroud)
现在是这样的
if(X.isin(newArray)
{ document.write( "YES");}
Run Code Online (Sandbox Code Playgroud)
这样的事情存在吗?:P