Removing brackets and text in crystal

I am using the following text to remove the brackets and text within the brackets; I need to drop the entire memo field and it stops after it finds and removes the first set of brackets and text.

if right({table.col},1) = "]" then
left({table.col},instr({table.col},"[")-1)
else
{table.col}

      

Any suggestions...

0


a source to share


1 answer


This has worked well with Crystal2008, not sure which version you are using, it also needs some error checking to handle mismatched bracket pairs, but it might offer a little food for thought:



Dim workString as String
Dim bracketedText as string

if (InStr ({table.col}, "[")> 0) then
  workString = {table.col}
  while (InStr (workString, "[")> 0)
    bracketedText = "[" + ExtractString (workString, "[", "]") + "]"
    workString = replace (workString, bracketedText, "")
  Wend
  Formula = workString
else
  Formula = {table.col}
End If

0


a source







All Articles