Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing last value in a string 3

Status
Not open for further replies.

kskid

Technical User
Mar 21, 2003
1,767
US
Crystal 8.5
Oracle 8i using Oracle ODBC driver

Did a search for parse but came up empty for my situation.

I need to parse out the last word or letter in a string

Example

This is a test
Here we go
a b c e f g

Expected results

test
go
g




 
try this:

mid(rtrim({table.field}),InstrRev(rtrim({table.field}), " ")+1)

~Brian
 
Try:

mid({table.string},instrrev({table.string}," ")+1)

-LB
 
Almost simultaneous post, Brian, but not quite!

You could also use:

split({table.string}," ")[ubound(split({table.string}," "))]

-LB
 
Or another fun means is:

split(trim({table.field})," ")[ubound(split(trim({table.field})," "))]

This allows for selecting any word by referencing it's position in the array index.

-k
 
Yeah, it was probably very close LB.

It would be nice if they put the time stamp on the post along with the date stamp.

Speaking of it would be nice's, are they ever going to fix the "My Info" page?

~Brian
 
Brian,

The My Info page is in the works and should be back soon, as far as I know...

-LB
 
Thank you all! A star for each of you

I figured it out in a round about way but it wasn't as elegant as all of you.

stringvar s:= strreverse({table.field});

if instr(s," ") = 0 then
{{table.field}}
else
right({table.field},instr(s," ")-1)
 
Witchita: I think that yours looks great, the only potential gotcha is if the field is padded with spaces at the end, so adding a trim might help to ensure success.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top