Question
· May 3, 2019

Extract string

Hi There

I created function to manage string as requirement  extract the first two letter of each word after space for example:

Text = "Review symptoms to report with patient"

After passed function it will be return "Resytorewipa"

ChangeFormat(desc)

   set desc = "Review symptoms to report with patient"
   q:$g(desc)=""
   SET delim=" "
   SET countdown=$LENGTH(desc,delim)
   set =1
   for
    {
        q:i>countdown
         set abbrv = $e($PIECE(desc,delim,i),1,2)   // But if I put w abbrv  I can get "Resytorewipa"
         set = i+1     
    }
   w abbrv

However, at the end I got only  abbrv=''pa"  how to get data as requirement.

Discussion (6)0
Log in or sign up to continue