Android Iritiate Through String For Specific Letter
I have a string, and I can detect if it has an # inside it. if(title.contains('#')){ SpannableString WordtoSpan = new SpannableString(title); int idx = tit
Solution 1:
use title.split("#") to get a array of strings which contains #.
Something like:
Stringparts= title.split("#");
for(inti=0; i<parts.length(); i++){
//TODO: do something with the string part//parts[i], this is a part of the string.
}
Solution 2:
You can use the Pattern to find and match words that contain hashtags in a given string.
Stringtext="I love chicken #burger, because they are #delicious!";
PatternHASHTAG_PATTERN= Pattern.compile("#(\\w+|\\W+)");
Matchermat= HASHTAG_PATTERN.matcher(text);
while (mat.find()) {
Stringtag= mat.group(0);
//String tag will contain the hashtag//do operations with the hashtag
}
Post a Comment for "Android Iritiate Through String For Specific Letter"