TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Get data between single quotes Android
Chintan Rathod
Jun 25, 2013
3.7
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
Split strings which is between single quotes (')
When you have string like "Chintan Rathod '
[email protected]
' place 'ahmedabad'" and you want to fetch out string which are between single quotes ('), then following code will do this thing.
Code
------
int second_index = 0;
int first_index = 0;
String str = "Chintan Rathod '
[email protected]
' place 'ahmedabad'";
while (true) {
if (second_index == 0)
first_index = str.indexOf("'", second_index);
else
first_index = str.indexOf("'", second_index + 1);
if (first_index == -1)
break;
second_index = str.indexOf("'", first_index + 1);
if (second_index == -1)
break;
String temp = str.substring(first_index + 1, second_index);
Log.d("TAG",temp);
}
Output
--------
06-25 17:39:56.079:
[email protected]
06-25 17:39:56.079: ahmedabad
Get data between single quotes Android
Next Recommended Reading
Using Facebookâs Rebound Spring Animations for Android in Xamarin.Android & other Dot Net Projects