我正在尝试从txt文件中提取特定的单词,使用一个Java的字符串输入。

huangapple 未分类评论46阅读模式
英文:

Im trying to extract specific words from txt file with an String input for java

问题

So far:

我扫描了一个包含诸如("monster, lobster, chopper").txt文件。

如果我使用了一个scanner类输入//对于我的输入,我想输入"er"

我该如何能够打印出在.txt文件中包含"er"的单词?

英文:

So far:

I scanned a .txt file which includes words such as ("monster, lobster, chopper")

If I used a scanner class input //for my input I would like to input "er"

how would I be able to print the words in the .txt that include "er"?

答案1

得分: 0

你可以使用string.Contains("er")来检查这个词是否与你的模式匹配。

英文:

you can use string.Contains("er") to check if the word matches your pattern or not

huangapple
  • 本文由 发表于 2020年4月11日 12:00:41
  • 转载请务必保留本文链接:https://java.coder-hub.com/61151982.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定