Import Double quotes within Double Quotes
Bruno Barthélemy
barthelemy at bbsoft.ch
Mon Dec 15 05:29:47 EST 2014
Hi Mats,
> Le 15 déc. 2014 à 11:01, ADJob <mats at adjob.se> a écrit :
> Question: Is there a way to detect the difference between this two strings?
>
> string 1 text outside ”text inside ”and within inside” inside quotes”
> string 2 text outside ”text inside” and the second "inside quotes”
A hint :
If the text is standardized, the string '(kSp)(kDq)' [or '(kDq)' if mid(lv_STRING;1;1=kDq] would start a quotation
whereas '(kDq)(kSp)' [or '(kDq)' if mid(lv_STRING;len(lv_STRING);1=kDq] would end it.
HTH
--
Bruno Barthélemy
BB-Soft
Pavement 9
1018 Lausanne
Switzerland
T +41 21 312 29 49
F +41 21 312 45 54
E barthelemy at bbsoft.ch
> Le 15 déc. 2014 à 11:01, ADJob <mats at adjob.se> a écrit :
>
> Hi all,
>
> The challenge:
>
> Example string: This import "string contaning ”within quotes” etc” and so on
>
> The spaces should be replaced with kTab (tabulator) outside the quotes and kSp (space) within the double quotes:
>
> This(kTab)import(kTab)string(kSp)containg(kSp)text(kSp)”within(kSp)quotes”(kSp)etc(kTab)and(kTab)so(kTab)on(kCr)
>
> So far i have managed to do this in a slow way looping character by character:
>
> For lv_POS from 1 to len(lv_STRING) step 1
> If mid(lv_STRING;lv_POS;1)=kDq ;; turn on and off the kTab - start and end of kDq
> Calculate lv_kDq as pick(lv_kDq;kTrue;kFalse)
> End If
> If lv_kDq=kFalse
> If mid(lv_STRING;lv_POS;1)=kSp
> Calculate lv_STRING as con(mid(lv_STRING;1;lv_POS-1);kTab;mid(lv_STRING;lv_POS+1;len(lv_STRING)))
> End If
> End If
> End For
>
> There is two problems. This is slow and it does not work if there is quotes within quotes.
>
> Question: Is there a way to detect the difference between this two strings?
>
> string 1 text outside ”text inside ”and within inside” inside quotes”
> string 2 text outside ”text inside” and the second "inside quotes”
>
> I have tried with strtok() that is faster, but the embedded double quotes is not detected in a correct way.
>
> Thanks in advance for any clue,
>
> Mats_____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
More information about the omnisdev-en
mailing list