Javascript:将文本区域的每一行与另一个文本区域的所有行进行比较
我需要将文本区域“a”的每一行与文本区域“b”的所有行进行比较,并使用“b”中不存在的“a”的所有项目创建一个alert(),
我该怎么做?
I need to compare each line of textarea "a" with all lines of textarea "b" , and create an alert() with all items of "a" who doesn't exists in "b"
¿ How can i do this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是获取 2 个文本区域的值,并将它们拆分为换行符 (
\n
)。然后,您可以迭代第一个文本区域的行并检查它们是否出现在第二个文本区域中:很可能有更好的方法,而且我确信上面的方法远非完美。这就是首先想到的。这是一个工作示例。
One way could be to get the values of the 2 textareas and split them on newline (
\n
) characters. You can then iterate over the lines of the first textarea and check to see if they appear in the second textarea:There may well be a better way, and I'm sure the above is far from perfect. This is just what came to mind first. Here's a working example.