C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Get data between single quotes Android
WhatsApp
Chintan Rathod
11y
3.9
k
0
0
25
Blog
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
Up Next
Using Facebook’s Rebound Spring Animations for Android in Xamarin.Android & other Dot Net Projects
Ebook Download
View all
Printing in C# Made Easy
Read by 22.5k people
Download Now!
Learn
View all
Membership not found