search inside brackets



  • hi all,

    can any one help me?

    in a RTF file I want to find all “\hich\af1\dbch\af31505\loch\f1” (or part of it) inside the brackets “[ ]”.

    in this example: [NAW_NAW\hich\af1\dbch\af31505\loch\f1 1]   and    [STARTSECTIE:STORNOS(AND STOR.AANNR=[BZWSCHRIFT_AAN\hich\af1\dbch\af31505\loch\f1 NR])]

    \fs19\lang1024\langfe1024\langnp2057\insrsid10121777 {*\bkmkstart blwaan}
    \par \hich\af1\dbch\af31505\loch\f1 [STARTSECTIE:NAW(and snaw.subjectnr = [BZWSCHRIFT_GEMACHTIGDENR])][NAW_NAW\hich\af1\dbch\af31505\loch\f1 1]\line [NAW_NAW2]}{\rtlch\fcs1 \af1 \ltrch\fcs0 \lang1024\langfe1024\langnp2057\insrsid10121777
    \par }\pard\plain \ltrpar\s25\ql \li0\ri0\sl280\slmult0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\pararsid9908172 \rtlch\fcs1 \af1\afs19\alang1025 \ltrch\fcs0
    \fs19\lang1024\langfe1024\loch\af1\hich\af1\dbch\af31505\cgrid\noproof\langnp1043\langfenp1043 {\rtlch\fcs1 \af1 \ltrch\fcs0 \lang1024\langfe1024\langnp2057\insrsid10121777 \hich\af1\dbch\af31505\loch\f1 [NAW_NAW3]\line {*\bkmkend blwaan}
    \hich\af1\dbch\af31505\loch\f1 [BETALING_REEDSBET]}{\rtlch\fcs1 \af1 \ltrch\fcs0 \insrsid8744553 \tab }{\rtlch\fcs1 \af1 \ltrch\fcs0 \insrsid3617139 \hich\af1\dbch\af31505\loch\f1
    -[EINDESECTIE:BETALING] [STARTSECTIE:STORNOS(AND STOR.AANNR=[BZWSCHRIFT_AAN\hich\af1\dbch\af31505\loch\f1 NR])]\tab \hich\af1\dbch\af31505\loch\f1 [STARTSECTIE:DUMMY(where ‘[STORNOS_REEDSTER1]’ > ‘0’)]
    \par }\pard\plain \ltrpar\ql \li0\ri0\sl-280\slmult0\widctlpar\tx5387\tqr\tx7088\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af1\afs19\alang1025 \ltrch\fcs0



  • Hello, @anita-nieuw and All,

    I noticed, in your text, that the string \hich\af1\dbch\af31505\loch\f1 is located, principally, near a closing square bracket ]

    So, here is a possible regex to match this string inside a brackets block :

    SEARCH (?-i)\Q\hich\af1\dbch\af31505\loch\f1\E(?=[^\r\n[]*?])

    Of course, you must set the Regular expression search mode !


    Notes :

    • First, the modifier (?-i) forces a NON-insensitive to case search

    • Then, the part \Q\hich\af1\dbch\af31505\loch\f1\E, due to the boundaries \Q and \E, looks for the literal range of characters, between them

    • But an overall match implies that the look-ahead (?=[^\r\n[]*?]), in other words, the condition is true.

    • That is to say, that, after the string \hich\af1\dbch\af31505\loch\f1, there is, further on, a closing square bracket ] and between, the shortest optional range of characters, different from, either, the opening square bracket [ and the End of Line characters \r and \n

    • For instance, for your two occurrences, found in your example, the [^\r\n[]*? part of the regex matches a space character followed by the digit 1 or the string NR, both, right before the ]

    Best Regards,

    guy038



  • GREAT, thank you very, very much! I’m happy :)


Log in to reply