• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

String Operations

 
Greenhorn
Posts: 26
Firefox Browser Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,


i have doubt from string operations. that is normally we can split string using some key words such as stringtokenizer and split functions. But now i want spliting string using general string concepts insteadof stringtokenizer and split keywords.



with regards,
sasikumar


thanks to advane
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to CodeRanch!

I'm not quite sure what you might mean by "general string concepts", but perhaps you're thinking of regular expressions? Have a look at the java.util.regex.Pattern class to see if that will meet your needs.
 
ssasi kumar
Greenhorn
Posts: 26
Firefox Browser Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,
ok i will check java.regex package. but generally using java.regex package concept are understanding java experts only. so if you dont mind how do working normal string concepts using perform to stringtokenizer functions .
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ssasi kumar wrote: normal string concepts.



Again, I have no idea what you mean by this. Maybe an example would help me?
 
Ranch Hand
Posts: 87
Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at string functions like substring(..) , indexOf(..) , lastIndexOf(..) , charAt(..) etc.

For example , the below code will print 1.
 
Ranch Hand
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why not use toArray() ... if regex is not what you are looking for
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because String does not have a toArray() method perhaps?
 
Lalit Mehra
Ranch Hand
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Because String does not have a toArray() method perhaps?



what about ... toCharArray() ...

i was just trying to put the logic up not the exact method name ...

anyways thanks Rob ...

 
Rob Spoor
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
toCharArray() should only be used if you really need a char[], because it creates a new char[]. If you only need to access characters from the String you should use length() and charAt(int) instead.
 
lowercase baba
Posts: 13082
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

prem pillai wrote:Have a look at string functions like substring(..) , indexOf(..) , lastIndexOf(..) , charAt(..) etc.

For example , the below code will print 1.



What about this is unclear? What would you expect this to print? Why do you think this is wrong? We can't help you if you don't explain what you think the problem is.
 
prem pillai
Ranch Hand
Posts: 87
Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:
What about this is unclear? What would you expect this to print? Why do you think this is wrong? We can't help you if you don't explain what you think the problem is.



I am clear about what I have pasted in this thread .... but looks like you are not at all clear about "who is asking for help ?" & "what is he asking for ?"

The person who initiated this thread is asking for various ways to split a string without using Stringtokenizer or split() method etc

Anyways thanks for asking me so many questions

Peace
 
Marshal
Posts: 76862
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ssasi kumar wrote: . . . split string using some key words such as stringtokenizer and split functions. . . .

Careful. Those aren't keywords.
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic