String Parsing exercise - E-Mail retrieved property

(imported topic written by brolly3391)

Using relevance, I want to turn this string:

Office (Network),9AA,CN=Brolly M Brolly/OU=XXX/OU=YYY/OU=US/O=Company

into this string:

brolly.m.brolly@company.com

Caveats:

Brolly M Brolly is a name and might have a different number of items, such as Brolly Brolly or Brolly M Brolly III.

There will be no “/” or “=” characters in the name.

There are an undertermined number of OU= entries in the middle of the string, each delimited with “/”.

My first approach

q: substrings separated by “,” of string “Office (Network),9AA,CN=Brolly M Brolly/OU=XXX/OU=YYY/OU=US/O=Company”

A: Office (Network)

A: 9AA

A: CN=Brolly M Brolly/OU=XXX/OU=YYY/OU=US/O=Company

T: 0.152 ms

I: plural substring

OR

q: substrings separated by “/” of substring after “CN=” of string “Office (Network),9AA,CN=Brolly M Brolly/OU=XXX/OU=YYY/OU=US/O=Company”

A: Brolly M Brolly

A: OU=XXX

A: OU=YYY

A: OU=US

A: O=Company

T: 0.196 ms

I: plural substring

How do I choose just the first and last substrings in my plural substring set for further parsing? I reviewed the Windows Inspector Library but I did not find much on how to work with plural objects. I would really love to learn how to process plurals so that I can move forward with this approach.

And the second approach, avoiding plural substrings

q: ((preceding text of first “/” of it & “@” & following text of last “O=” of it & “.com” )of substring after “CN=” of string “Office (Network),9AA,CN=Brolly M Brolly/OU=XXX/OU=YYY/OU=US/O=Company”) as lowercase

A: brolly m brolly@company.com

T: 0.262 ms

I: singular string

It’s messy, and it works but it does not teach me anything new about handling plurality. And there is still the question of replacing the spaces in the name with dots without knowing how many spaces there will be.

Any ideas, gang?

(imported comment written by jessewk)

Try this:

(concatenation “.” of substrings separated by " " of preceding text of first “/” of following text of last “CN=” of it & “@” & following text of last “/O=” of it & “.com” ) of “Office (Network),9AA,CN=Brolly M Brolly/OU=XXX/OU=YYY/OU=US/O=Company”

Brolly.M.Brolly@Company.com

Evaluation time: 0.174 ms

Evaluates to singular object of type string

This is basically the same as your last query above.

As for your question on only selecting certain results of a plural string, you would need to use a ‘whose’ clause to filter the results you don’t want. Here’s an example using your first approach:

(it & “.com”) of (concatenation “.” of substrings separated by " " of concatenation “@” of (if (it starts with “O=”) then following text of first “O=” of it else it) of substrings separated by “/” whose (it does not contain “OU=”) of substring after “CN=” of “Office (Network),9AA,CN=Brolly M Brolly/OU=XXX/OU=YYY/OU=US/O=Company”)

Brolly.M.Brolly@Company.com

Evaluation time: 0.215 ms

Evaluates to singular object of type string

To me, the first version is easier to understand.

Hope that helps.

-Jesse

(imported comment written by brolly3391)

Thanks jessewk,

Nice use of the concatenation command. I will take that and run with it.

To give you a touch of background on why I wanted it. Lotus Notes once it is set up for an end user’s E-mail, has a Notes.ini file that can be parsed to extrapolate the user’s e-mail address. The finished relevance for my retrieved property is:

q: if (exists folder “c:\program files\notes” whose (exists file “notes.ini” whose (exists section “Notes” whose (exists key “Location” whose (it as string contains “CN=” AND it as string contains “Office (Network)”)of it) of it)of it)) then ((concatenation “.” of substrings separated by " " of preceding text of first “/” of following text of last “CN=” of it & “@” & following text of last “/O=” of it & “.com” ) of key “Location” of Section “Notes” of File “Notes.ini” of folder “c:\program files\notes”) as lowercase else nothing

A: brolly.m.brolly@company.com

T: 2.230 ms

I: plural string

I hard coded the folder to our Lotus Notes 5x or 6x and 7x install location but that could of course be changed to match different locations. I am explicitly searching for the Office (Network) Location because I know that one formats out correctly.

It’s very nice to be able to see an E-Mail address column in the console. Makes putting together Pilot Test groups much easier. It also lets me compare visually to the User Name field. It lets find the “my logon does not match my e-mail” people for remediation.

(imported comment written by brolly3391)

OK,

I could not leave it alone… I had to find the reg key of where notes is installed (good on Lotus Notes 5x 6x and 7x, maybe more) and use that path instead of our hard coded value.

q: if exists folder (if (exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Lotus\Notes” whose (exists value “Path” of it) of registry) then (value “Path” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Lotus\Notes” of registry as string) else ("")) whose (exists file “notes.ini” whose (exists section “Notes” whose (exists key “Location” whose (it as string contains “CN=” AND it as string contains “Office (Network)”)of it) of it)of it) then ((concatenation “.” of substrings separated by " " of preceding text of first “/” of following text of last “CN=” of it & “@” & following text of last “/O=” of it & “.com” ) of key “Location” of Section “Notes” of File “Notes.ini” of folder (value “Path” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Lotus\Notes” of registry as string)) as lowercase else “not set”

A: john.talbert@certegy.com

T: 2.569 ms

I: plural string

Also, on BES 5.1 I was getting in the console when I finished the phrase with the “else nothing” so I changed it to "else “not set” for a cleaner look. I guess I could get even deeper with it and determine if it is “not set” becuase Notes is not installed or just not set up, and report accordingly, but that is a story for another day.

(imported comment written by neilhenderson)

Hi

We are currently migrating users from Lotus Notes to Outlook (Exchange). Is there any way to retrieve a property to show the users email address? I cant seem to find any files or registry entries relating to this.

Thanks

Neil Henderson