Template trouble -- hidden characters in a string in an attribute for the "last notification received" phone app sensor

I have the Alfred Front Door Lock which can be operated via z-wave. I am trying to create an automation that will unlock the door when certain members of my contacts simply text “unlock” to my phone number when arriving. I sent myself a text message to help figure out how to implement it. The name of the contact appears in the “android.title” attribute of the last notification received phone app sensor (when said attribute exists). The content of the message is contained in the “android.text” attribute. I am setting the trigger to be when “android.text” has the value “unlock” and would like to set a template condition to requiring the value in “android.title” to be an element of a given permission list.
When testing in dev tools, the is_state_attr(“sensor…”, “android.text”, “unlock”) matches perfectly fine. However when testing if “android.title” matches to the appropriate string it returns false, even though they print identically to the screen. I used the length filter and the problem seems to be that the length of the “android.title” field is two characters more than it “should” be. (e.g. if the value in android.title prints as “david” its length is 7 instead of 5). I was also able to determine these hidden characters correspond to the [0] and [last] entries in the string. Is there a way to select simply the substring that I want or append these extra “hidden” characters to the strings in my permission list so they will match when comparing with the is_state_attr() function?