English 中文(简体)
• 如何检查 j壁画中的特征的下一个存在
原标题:how to check next existence of a character in string in javascript
  • 时间:2011-11-22 06:50:40
  •  标签:
  • javascript

今天,我有这样的经历。

var data= mobile,car,soap,room ;

我从这种扼杀中汲取教训,把这种扼杀作为 com,把它推入像这样的阵列。

var availableTags=[];
var str=  ;
for(i=0;i<data.length;i++)
{
  if(data[i]== , )
  {    
    availableTags .push(str);
    str=  ;
  }
  else
  {
    str +=data[i];
  }
}

但我这样做是错误的,因为我无法在 com后获得最后价值...... 现在 我想问一下,我如何了解一下,在我所说的话中,是否存在着“<条码>。 因此,我还可以包括最后价值。

我也希望有人告诉我,我如何能够以其他方式完成同样的任务。

我想,这块地势是一阵,它应当像这样看待。

  ["mobile","car","soap","room"]
最佳回答

您可以使用:

data.split(/,/)

split

问题回答

页: 1

var availableTags = data.split(",");

它将处理所有事项。 这将形成一个阵列。

在休息之后,你需要检查<代码>>>>>><>/代码>的价值,并加起来。 它可以包含最后 com号之后的其余部分,或在 com号是<编码>数据的最后特性时可以空出。

但正如其他发言者指出的那样,<代码>ssplit<>/code>或许是这样做的更好途径。

在确定现有职能方面,试图在<<>条码>后添加以下内容: 住宿:

if (str != "")
   availableTags.push(str);

(如航程结束,<代码>str 持有上 com之后的任何东西。

但正如其他答复一样,你只能使用<条码>。

var availableTags = data.split(",");

您可以在一开始补充 com子:

data = data + ","

......





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签