• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java code to Search String for first occurrence and return remaining string between "".

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me with Java code to Search String for first occurrence and Return remaining string between "".

Example:

String:  Some Text to search, "Missing field". A friendly place for programming greenhorns!

Search for:: Some Text to search,
Return:  "Missing field"

Please check below working code for string counter and help me with required solution. Thanks



 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

You had the code tags wrong, but I have corrected that for you. Don't post the same post twice; I have deleted the duplicate.

Where are you searching the String? I can see some file reading code which appears to be in a class called Search, but that won't compile. I think you have a line missing. You are also counting occurrences in an array, but that is obviously something different. Do you know how to use the methods of the String class to find an included substring? Do you know how to work out the length of that substring? Do you know how to use another String method to find the remainder of the String as a substring?
What are you going to do it the search text is not found, or there are no quote marks?
 
Nitish Nagar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.

Yes, i have mistakenly put wrong code here and of course, counting occurrences is not required here.

Can you please brief me how to fetch the remaining string using "length of that substring" and "remainder of the String as a substring".

Regards
Nitish
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nitish Nagar wrote:
Yes, i have mistakenly put wrong code here and of course, counting occurrences is not required here.



So, now that you noticed that you posted the wrong code, why don't you post the right code? We don't know what you did so far, nor can easily determine what your mistakes are, until you do.

Henry
 
Nitish Nagar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please help me with Java code to Search String for first occurrence and Return remaining string between "".

Example:

String:  Some Text to search, "Missing field". A friendly place for programming greenhorns!

Search for:: Some Text to search,
Return:  "Missing field"



Please post solution of my question instead. Thanks
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nitish Nagar wrote:
Please post solution of my question instead. Thanks



Unfortunately, this is not in the spirit of the ranch. The ranch is a learning site. If you have a specific question, we can answer it, or hint you towards it. If you are stuck on an error, we can help you towards understanding it, or locating it. If you are stuck on code, we can help you locate your issue. Regardless. you will need to do the heavy lifting, as that is the best way to learn.

Henry
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic