IPeople Blog

MAGIC function for returning the number of leading characters

Written by Gary | Nov 4, 2021 5:00:00 AM

l (that's a lowercase L) is the MAGIC function for returning the number of leading characters for a string.  It takes two arguments, the first of which is the string to search for leading characters, and the second of which is the character to check for. 

 l(0009876,0) returns 3 because the string 0009876 has three leading characters that match the second argument, 0.

This comes in handy on occasion, especially when creating a user-defined field that performs string extraction based upon the number of leading characters within a string.  Some facilities have their patient account numbers beginning with a long string of zeros and need those zeros excluded from the report.  Sometimes the number of leading zeros varies.