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

How to extract a part of a long string?

Status
Not open for further replies.

wwl1txm

Technical User
Dec 13, 2001
4
NL
I have a long string containing the /OU part of a AD. This part is not always on the same place in the string. Does anyone knows how to extract this part and the following 4 characters?

Thanks,
 
You can get the four characters after the "/OU" using
Code:
Left(Split({field}, "/OU")[2]), 4)
If you want the key characters as well, you could do
Code:
"/OU" & Left(Split({field}, "/OU")[2]), 4)


[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Thanks for your quick answer, however when I try this I am getting an error messages that the matrix should be between 1 and the maximum value? Any idea?

Thanks
 
What is the exact error message? I've never seen a reference to a matrix. Can the field be null? Can the number of characters after "/OU" sometimes be less than 3? Try the following:

if isnull({field}) or
ubound(split({field},"/OU")) < 2 or
Split({field}, "/OU")[2]) < 4 then
"Error" else
"/OU" & Left(Split({field}, "/OU")[2]), 4)

If this still doesn't work, you should provide samples of the field that include all variations.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top