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!

Extract part of a string 1

Status
Not open for further replies.
Jun 26, 2002
77
US
I have been reading the posts but have not found a solution to my issue.
I have a field that for Network Login ID shown as:

.JDOE.TW.VIS_PC.HBCD
.SSMITH.AGNYMIS.HHSA

I need to extract the string following the second period. For example the above two records would be

TW.VIS_PC.HBCD
AGNYMIS.HHSA

I am using CR XIR2

Thank you.
 
I have not tested these for values exactly like yours, but this should at least provide a push in the right direction:

Create 3 formulas:
1. {@Split1}
Split({YourTable.YourField},".")[Ubound(Split({YourTable.YourField},"."))]

2. {@Split2}
Split({YourTable.YourField},".")[Ubound(Split({YourTable.YourField},"."))-1]

3. {@SplitShow}
{@Split2}& " " & {@Split1}

Place formula 3 in your report.


OR


If the 1st "." is always the 1st character in the field:

1. {@FieldLEN}
LEN(TRIM({YourTable.YourField}))

2. {@No1Dot}
RIGHT(TRIM({YourTable.YourField}),({@FieldLEN}-1))

3. {@InNo1Dot}
InStr({@No1Dot},".")

4. {@WhatYouWant}
RIGHT({@No1Dot},(({@FieldLEN}-1)-{@InNo1Dot}))



Again, this is untested.

 
stringvar x := {table.string};
mid(mid(x,2),instr(mid(x,2),".")+1)

-LB
 
Thank you.

I was actually able to get this resolved using a different method as follows:

Create 3 formulas:
1. //Replaces the first dot in field with ~
{@Replace1}
Replace ({Sheet1_.DN},"." ,"~" ,1 ,1 )

2. //Replaces the dot after the text to be removed with &
{@Replace2}
Replace {@Replace1},"." ,"&" ,1 ,1 )

3. // Trims text to character following & which is the starting point of wanted text.
{Removetext}
Mid({@Replace2},Instr({@Replace2},"&")+1)

Placed formula 3 on report.
 
leave it to lbass to come up with a excellent and concise solution!


also, upon review, I don't think you need the "-1" in my {@WhatYouWant} formula:

4. {@WhatYouWant}
RIGHT({@No1Dot},(({@FieldLEN}-1)-{@InNo1Dot}))

so it should read:
4. {@WhatYouWant}
RIGHT({@No1Dot},(({@FieldLEN})-{@InNo1Dot}))
 
lbass...you are a genious. We do it the hard way and you do it the easy way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top