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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Splitting

Status
Not open for further replies.

ChiTownDiva

Technical User
Jan 24, 2001
273
US
Happy Hump Day All!!!

I've got a string splitting problem.

I need to split a field where sometimes they look like this:

9191/ 9191 Compliance Assistant (two spaces between the "/" and the second "9191" and one space between "9191" and "Compliance Assistant")

Sometimes they look like this:

0000/ P0604 Manager (one space between the "/" and the "P0604" and one space between "P0604" and "Manager")

Or this:

9199/000000 Sales Associate (one space between "9199/000000" and "Sales Associate")

The one thing they all have in common is that there is only one space between the job function (i.e. "9199/000000") and the job title (i.e. "Sales Associate").

All I need to show is the job title (i.e. "Sales Associate"). I've tried:

Right(Trim({Names}),Len(Trim({Names}))-InStr(1, {Names}," "))

but this doesn't work in all cases.

Does anyone have any ideas?

Thanks in advance for your help.

ChiTownDiva [ponytails2]

 
Here you go. It works with the examples you show.

stringvar a:="9191/ 9191 Compliance Assistant " ;//replace with your field
stringvar slash:=trim(mid(a,instrrev(a,"/")+2));
mid(slash,instr(slash," ") )

Mike
 
Thanks Mike...

I used your code and got the following error message:

"Start position is less than 1 or not an integer"

ChiTownDiva [ponytails2]
 
The only way I was able to replicate the error was when there was no space between the function and title. Are there any occasions of this in your field? I've added a "+1" in the last line. It can be used to see if there are any "freaky" formats to your field. You'll end up with (using the example below) 000Manager, and the correct results if the format is correct.

You should also add a trim (I forgot it) to the last line.

stringvar a:="9191191 /3000Manager " ;//replace with your field
stringvar slash:=trim(mid(a,instrrev(a,"/")+2));
trim(mid(slash,instr(slash," ")+1 ) )

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top