| Author |
Substring from a specific word
|
Raj kalaria
Ranch Hand
Joined: Sep 08, 2005
Posts: 70
|
|
Hi I hava a string sql sql = select object_name, tilte, subject from dm_document where Now if i want a susbstring say newsql = object_name, tilte, subject how can i acheive this sql.substring( ) ??? pla help
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
|
Sorry, but I'm not understanding what you need to do. Can you provide more detail on your critera for creating the substring?
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Raj kalaria
Ranch Hand
Joined: Sep 08, 2005
Posts: 70
|
|
yeh see i have a string string abc = "select object_name, tilte, subject from dm_document where" Now i want a susbstring from abc containing "object_name, tilte, subject" that is newabc = "object_name, tilte, subject" how can i achieve this
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
StringTokenizer or String.split() will split a string on some delimiter. You could replaceAll() commas with spaces and use a space delimiter to process the words one at a time: Try that and see how it works. Then we can talk about regular expressions. If you don't know them they are significantly trickier and could "capture" all the text between "select" and "from" and probably even capture one word at a time.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
Raj kalaria
Ranch Hand
Joined: Sep 08, 2005
Posts: 70
|
|
Hi james thanks for yr input i will defi try that but for time bieng i did as follow --------------****************--------------------------- int pos = str.indexOf( "select"); int pos1 = str.indexOf( "from"); String str1 = str.substring(6,pos1); ---------------************-------------------- but i am not happy with the logic . I will look to yr logic thanks a lot Raj
|
 |
 |
|
|
subject: Substring from a specific word
|
|
|