计算字符串中子字符串的频率 [英] counting frequency of a substring in a string

查看:142
本文介绍了计算字符串中子字符串的频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试计算字符串中的子串数。我对编程很新,需要一个头脑。任何信息,将不胜感激。


谢谢,

A

Hi,
I am trying to count the number of substrings within a string. I am fairly new to programming and need a headstart. Any info would be appreciated.

Thanks,
A

推荐答案




我正在尝试计算字符串中的子串数。我对编程很新,需要一个头脑。任何信息,将不胜感激。


谢谢,

A
Hi,
I am trying to count the number of substrings within a string. I am fairly new to programming and need a headstart. Any info would be appreciated.

Thanks,
A



你能否提出你的问题,我无法理解你是什​​么意思的子串和你想要搜索它的基础。


Can you elobrate your question, I m unable to understand what you mean by substring and on what basis you want to search it.


一个简单的方法是从字符串中找到子串的第一个字符的每个出现开始,然后在每次出现检查以查看子串是否存在。
Well a simple method would be to start by finding each occurance of the first character of the substring in the string, then at each occurance check to see if the substring exists there.


我想检查单词Hi在句子中出现的次数

嗨我当我访问高山时感觉真的很高
I want to check how many times the word Hi has occured in the sentence
"Hi I feel really High when I visit High Mountains"


这篇关于计算字符串中子字符串的频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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