I have notes that I exploded that contain the $Names of People but are in CamelCase Format in the $Name attribute.
Here are some example: TomDiaz of the $Name of one of my notes. but I have about 40 notes for future use.
I want to automate this with a stamp on my selected notes. I simply want to add a space between the CamelCase words. Here is an example of the parse I want
$FullName:Tom Diaz
$FirstName: Tom
$LastName: Diaz
As you have only 40 notes, and one is TomDiaz, let’s be optimistic and assume that most of these names are going to be straightforward. If we stumble on Björk or G. E. M. de Ste. Croix, you can adjust those notes manually.
One approach would be to use the extract() operator.
The operator .extract(pattern[, ignore_case]) returns the first matched subexpression of a regular expression. If the regular expression has no subexpressions, the entire match is returned.
So, the first name is one or more characters, up to the first uppercase character. In the example, Tom.
$FirstName=$Name.extract("(.+)[A-Z]");
We could use similar logic for the last name, but I’m anxious about **Gretchen McGillicuddy **. So, having found the first name, let’s put the rest into the last name and hope for the best:
Many thanks Mark. Very cool logic to use the size of the $FirstName to get the starting point of the $LastName. I learned many things today. Grateful.
One last observation: In a CamelCase name situation where TomD was used instead of the full last name, my thought I could use some error checking like if($LastName.size==0 | 1){$Color =“red”;};