I have a specific problem and hopefully I can explain it. I am processing a lot of cad-files. The strings in these cad files contain usually 8 values separated by spaces or tabs (or both) in variable amounts (one or more each). Also it's possible to encounter spaces/tabs at the beginning/end. Some lines are to be ignored, they start with a "*"; but it is possible that they have spaces/tabs in front of the "*".
I want to get a clear version of the string to extract the values. My current code is that:
Code: Select all
;Just for the Example
Define temp.s,start
temp=" 1 2 3 4 entry 6 dummy 8 "
;String processing
ReplaceString(temp,#TAB$," ",#PB_String_InPlace)
temp=Trim(temp)
If Len(temp)<>0 And Left(temp,1)<>"*"
start=FindString(temp," ")
While start
temp=ReplaceString(temp," "," ",#PB_String_CaseSensitive,start)
start=FindString(temp," ")
Wend
;Process String further...
EndIf
- Replace all tabs with space; inplace
- Trim the left and right spaces away
- Check if the string is empty or to be ignored
- If not: Find the first occurence of double spaces
- While there are double spaces in the string -> replace them with single spaces
Is there an approach that is faster? I am processing millions of entries.