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

STRING EXTRACTION 1

Status
Not open for further replies.

reidtw

MIS
Feb 10, 2004
74
GB
Hi,

I'm using CR8 with a Lotus Domino server.

I have this string field that lloks like this: -

CN=Joe Bloggs/OU=Investment/O=Company/C=GB

Does anyone know how I could extract the name "Joe Bloggs" from this field?

Ta
Trev
 
Is "CN=" always to first entry in the field? If so, this is fairly easy:

mid({table.field}, 4, instr({table.field}, '/') - 4)

Otherwise you'll need to find where "CN=" is. This is possible in one call, but I'll break it down using variables:

NumberVar start;
NumberVar end;
start := instr({table.field}, 'CN=') + 3;
end := instr({table.field, '/', start);
if start > 0 then
mid({table.field}, start, end-start);
else
""

I haven't tested this, so you may need to tweak the numbers a little, but the method should work.

-Dell


A computer only does what you actually told it to do - not what you thought you told it to do.
 
Or try:

if instr({table.field},"CN=") > 0 then
split(split({table.field},"/")[1],"=")[2]
else
"N/A"

There may be other sanity checks required, I just made sure that the CN= exists.

-k
 
Many thanks hilfy, yes, "CN=" is constant as a prefix to the field so I used your first suggestion, though I will probably play around with the other and the one from synapsevampire just in case things change!

Many thanks again.

Trev
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top