How to find a particular string in a paragraph in android?

In my project the data is stored in html format along with image tag. For example the following data is stored in html format and it contains 2 to 3 images.

Mother Teresa as she is commonly known, was born Agnes Gonxha Bojaxhiu. Although born on the 26 August 1910, she considered 27 August, the day she was baptized, to be her "true birthday". “By blood, I am Albanian. By citizenship, an Indian. By faith, I am a Catholic nun. As to my calling, I belong to the world. As to my heart, I belong entirely to the Heart of Jesus." img ----- src="image1.png" ----> Mother Teresa founded the Missionaries of Charity, a Roman Catholic religious congregation, which in 2012 consisted of over 4,500 sisters and is active in 133 countries.img ----- src="image2.png" ---->. She was the recipient of numerous honours including the 1979 Nobel Peace Prize. She refused the conventional ceremonial banquet given to laureates, and asked that the $192,000 funds be given to the poor in India. img ----- src="image3.png" ---->

Now from the above data I need to find how many images the paragraph has and need to get all the image names along with the extensions and should display them in android. Tried with splitting but did not work. Please help me regarding this.

Thanks in advance

Answers


you can use contains method of String class

String a="hello";
String b="hello my name is this";
if(b.contains(a)){

}

it will return true or false.


Check below for number of occurrences

  String searchFor = "is";
  String base = "This is the method";
  int len = searchFor.length();
  int result = 0;
  if (len > 0) 
  {  
     int start = base.indexOf(searchFor);
     while (start != -1) 
     {
        result++;
        start = base.indexOf(searchFor, start+len);
     }
  }
  System.out.println(result);

For More Det: http://www.roseindia.net/java/string-examples/java-string-occurrence-in-a-string.shtml


Try this,

Use BreakIterator Class

eg :

BreakIterator boundary = BreakIterator.getSentenceInstance();

      boundary.setText(Your_entire_string);

      int start = boundary.first();

      int end = boundary.next();

Then with the help of looping you can iterate through all the lines.


Need Your Help

How to maintain my SSD disk effectively?

linux trim ssd disk-partitioning defragmentation

I'm running Linux (kernel 3.18) over a SSD disk (with an Ext4 partition) with TRIM feature enable.

C++ and Win32: When do I have to release variables etc?

java c++ winapi jna

I am usually a Java programmer and my C++ days were over for at least 15 years. Now I use C++ to build me a bridge (dll) for some Win32 functions.