LOCAL lcString, lcUPC lcString = "Small Widget (1 12345 12345 1)" lcUPC = "112345123451" lcRemoved = RemoveUPC(lcString,lcUPC) CLEAR ?lcString ?lcRemoved FUNCTION RemoveUPC LPARAMETERS pcString,pcUPC LOCAL lnNdx, lcRemoved, lnPos, lnUPC, llFound lcRemoved = pcString lnNdx = ATC(pcUPC,pcString) IF lnNdx > 0 lcRemoved = STUFF(pcString,lnNdx,LEN(pcUPC),"") ELSE llFound = .F. FOR lnNdx=1 TO LEN(pcString) IF SUBSTR(pcString,lnNdx,1) = LEFT(pcUPC,1) lnPos = lnNdx lnUPC = 1 DO WHILE lnUPC<=LEN(pcUPC) .AND. SUBSTR(pcString,lnPos,1) = SUBSTR(pcUPC,lnUPC,1) lnUPC = lnUPC + 1 IF lnUPC > LEN(pcUPC) llFound = .T. EXIT ENDIF lnPos = lnPos + 1 DO WHILE SUBSTR(pcString,lnPos,1) = " " && Check for embedded spaces -- skip past lnPos = lnPos + 1 ENDDO ENDDO ENDIF IF llFound lcRemoved = STUFF(pcString,lnNdx,lnPos-lnNdx+1,"") EXIT ENDIF ENDFOR ENDIF RETURN lcRemoved ENDFUNC