Tinderbox Forum

Excluding trailing comma from firstWord()?

I have a series of good enough stamps to set note names for references. An example is:


There are edge cases (multiple authors, etc.) where I clean up manually after applying the stamp which is fine. However, because the value of $Authors is always formatted

Last Name, First Name

and the action firstWord($Authors) uses the space as the delimiter, the stamp always includes the comma along with the author’s last name, and I’d prefer to not delete it manually for every reference.

My problem is that I don’t know how to say “don’t include the comma” … Is there a simple way to do that?

I’m not sure you can fix this on the fly as a conditional is implied: "if the [Last name] ends in a comma and possible white space, delete the latter.

In fact, Tinderbox tends to trim padding start/end white space, so even if the last name recovered is ‘lastname, ’ you get ‘lastname,’. This makes it a bit easier to fix. So, post import, use code (stamp, rule, whatever):

$Name = $Name.replace(",$","");

Turns out that even if $Name actually has trailing whirte space, the above still works. Happiness.

[Tested in Tinderbox v9.2.1]

1 Like

Thanks for the clear example Mark.

I had no idea what the “$” did but your TbRef entry on .replace explains.

Revised, working stamp reads:



1 Like