Javascript 段落中单词的正则表达式

Javascript 段落中单词的正则表达式,javascript,jquery,regex,dojo,Javascript,Jquery,Regex,Dojo,一段文字的正则表达式,我想在其中搜索一个单词 我尝试使用.search,但没有得到正确答案,例如:- 科学(源于拉丁语scientia,意思是“知识”)是一项系统性的事业,它以可测试的解释和对宇宙的预测的形式构建和组织知识。[1]具有更古老和密切相关的意义(例如,在亚里士多德中发现) 在上面的句子中,如果我必须找到“知识”这个词。我可以使用什么正则表达式。 实际上,我已经在dojo中制作了一个表单:- 名称:文本区 地址:文本区 电话。编号:txt区域编号 提交按钮 现在当我点击提交按钮。姓名地

一段文字的正则表达式,我想在其中搜索一个单词

我尝试使用.search,但没有得到正确答案,例如:-

科学(源于拉丁语scientia,意思是“知识”)是一项系统性的事业,它以可测试的解释和对宇宙的预测的形式构建和组织知识。[1]具有更古老和密切相关的意义(例如,在亚里士多德中发现)

在上面的句子中,如果我必须找到“知识”这个词。我可以使用什么正则表达式。

实际上,我已经在dojo中制作了一个表单:-

名称:文本区 地址:文本区 电话。编号:txt区域编号

提交按钮

现在当我点击提交按钮。姓名地址和电话号码字段应自动填入一封信,如下所示:-

亲爱的[姓名]

这是告诉你,诸如此类。你可以联系下面的签名人。 [电话号码],[地址]

  • 我已经做了表格。现在,我正在尝试匹配标签的内部html和括号中的单词。如果它是相同的,则必须在字母中输入值。请帮忙提个好主意
  • 以下正则表达式:

    /knowledge/ig
    
    无论如何,我认为你不需要正则表达式:

    string.indexOf('knowledge'); // Will give you the first index of the word
    
    以下正则表达式:

    /knowledge/ig
    
    无论如何,我认为你不需要正则表达式:

    string.indexOf('knowledge'); // Will give you the first index of the word
    
    见此:

    但正如奥利所指出的,这是毫无意义的。考虑到您可能想要替换字符串知识,我也使用了替换函数:

    var str = 'Science (from Latin scientia, meaning "knowledge") is a systematic enterprise that builds and organizes knowledge in the form of testable explanations and predictions about the universe.[1] In an older and closely related meaning (found, for example, in Aristotle)';
    
    var match = str.match(/knowledge/gi);
    
    if(match != null)
    {
        for(var i = 0; i < match.length; i++)
            alert(match[i]);
    
        var replacedString = str.replace(/knowledge/gi,'egdelwonk');
        alert(replacedString);
    }
    
    见此:

    但正如奥利所指出的,这是毫无意义的。考虑到您可能想要替换字符串知识,我也使用了替换函数:

    var str = 'Science (from Latin scientia, meaning "knowledge") is a systematic enterprise that builds and organizes knowledge in the form of testable explanations and predictions about the universe.[1] In an older and closely related meaning (found, for example, in Aristotle)';
    
    var match = str.match(/knowledge/gi);
    
    if(match != null)
    {
        for(var i = 0; i < match.length; i++)
            alert(match[i]);
    
        var replacedString = str.replace(/knowledge/gi,'egdelwonk');
        alert(replacedString);
    }
    

    你试过的正则表达式在哪里?这很好地解释了js中的regex。你的问题很模糊。。。找到“知识”这个词很简单,但似乎毫无意义,因为你没有说一旦找到它你需要做什么,我猜这将是你问题中更重要的一部分。我写了整个问题你尝试过的正则表达式在哪里?这很好地解释了js中的regex。你的问题很模糊。。。找到“知识”这个词很简单,但似乎毫无意义,因为你没有说一旦找到它你需要做什么,我猜这将是你问题中更重要的一部分。我已经写了整个问题