如何获得包含特定单词的整句? [英] How to get whole sentence that contain particular word?

查看:67
本文介绍了如何获得包含特定单词的整句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何使用javascript获取包含特定单词的整个句子?。例如。

i有一个段落如下。我想找到包含单词'device'的句子



计算机是一种通用设备,可以编程执行一组算术或逻辑运算。由于一系列操作可以很容易地改变,计算机可以解决不止一种问题。





然后得到结果以下。



计算机是一种通用设备,可以编程执行一系列算术或逻辑运算。



谢谢......

解决方案

Hello Hasbina,



这里是关于如何做的想法 [ ^ ](在C#中)。

这里是 Javascript的正则表达式语法教程 [ ^ ]在JS中实现它。

请参阅如何在JS中使用RegExp对象 [ ^ ]



干杯,

Edo


参见..

使用-javascript-to-the-a-click-of-a-clicked-words [ ^ ]

Javascript -regexp-find-specific-sentence [ ^ ]

Hi,

How to get whole sentence that contain particular word using javascript?.for example.
i have a paragraph as below.in which i want to find the sentence that contain a word 'device'

A computer is a general purpose device that can be programmed to carry out a set of arithmetic or logical operations. Since a sequence of operations can be readily changed, the computer can solve more than one kind of problem.


then getting the result as below.

A computer is a general purpose device that can be programmed to carry out a set of arithmetic or logical operations.

Thanks......

解决方案

Hello Hasbina,

Here's the idea on how to do it[^] (in C#).
And here's Javascript's Regex syntax tutorial[^] to implement it in JS.
See tutorials on How to use the RegExp object in JS[^]

Cheers,
Edo


See..
Use-javascript-to-get-the-sentence-of-a-clicked-word[^]
Javascript-regexp-find-particular-sentence[^]


这篇关于如何获得包含特定单词的整句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆