I had to do something like this in XSLT. If the string is not too long (for some definition of "too long"), you can replace all newlines with "" and then take the difference in the two string lengths.
Greg has over 40 years of experience in software and hardware development. He has managed application, operating
systems, compiler, and database development groups; run multi-product documentation teams; directed customer service organizations; project-managed multi-million dollar projects; and directed product management and marketing operations groups. His experience includes liaison responsibilities with international organizations, particularly in Japan.