Sign in to follow this  
Followers 0
mLipok

SRE - Conditional - why I get additional empty elements

4 posts in this topic

The subject string to check

q
430.080 0 0 308.160 0.000 0.000 cm 
/im2 Do
Q 
BT
3 Tr
0.000 0.000 0.000 rg
28.800 284.400 Td
0.000 Tw
66.107 Tz
/F48 7.700 Tf
0 Ts
0.201 Tc
(1) Tj
0.000 Tc
(1) Tj
9.533 Tw
88.372 Tz
0.172 Tc
( Przesyłk) Tj
0.000 Tc
(ę) Tj
1.339 Tw
90.000 Tz
-0.106 Tc
( polecon) Tj
0.000 Tc
(ą) Tj
2.496 Tw
85.314 Tz
-0.013 Tc
( n) Tj
0.000 Tc
(r) Tj
151.392 Tw
90.000 Tz
-0.092 Tc
( doręczono) Tj
0.000 Tc
(:) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
33.480 270.000 Td
0.000 Tw
53.097 Tz
/F48 7.700 Tf
0 Ts
0.000 Tc
(l) Tj
5.387 Tw
106.195 Tz
( l) Tj
2.364 Tw
89.328 Tz
0.167 Tc
( adresatow) Tj
0.000 Tc
(i) Tj
99.884 Tw
128.044 Tz
-1.119 Tc
( [~) Tj
0.000 Tc
(|) Tj
1.208 Tw
90.000 Tz
-0.081 Tc
( dorosłem) Tj
0.000 Tc
(u) Tj
2.218 Tw
0.029 Tc
( domownikow) Tj
0.000 Tc
(i) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
33.480 252.720 Td
0.000 Tw
107.528 Tz
/F48 7.700 Tf
0 Ts
-0.353 Tc
(P) Tj
0.000 Tc
(]) Tj
4.862 Tw
90.000 Tz
0.084 Tc
( dozorc) Tj
0.000 Tc
(y) Tj
0.898 Tw
-0.132 Tc
( dom) Tj
0.000 Tc
(u) Tj
93.888 Tw
125.874 Tz
-1.199 Tc
( [~) Tj
0.000 Tc
(|) Tj
1.985 Tw
87.636 Tz
0.135 Tc
( sołtysow) Tj
0.000 Tc
(i) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
212.400 238.320 Td
0.000 Tw
100.480 Tz
/F48 7.700 Tf
0 Ts
-0.796 Tc
(i—) Tj
0.000 Tc
(i) Tj
1.511 Tw
90.000 Tz
0.093 Tc
( adresatowi) Tj
0.000 Tc
(,) Tj
1.160 Tw
-0.010 Tc
( któr) Tj
0.000 Tc
(y) Tj
0.734 Tw
90.558 Tz
-0.181 Tc
( ni) Tj
0.000 Tc
(e) Tj
0.069 Tw
90.000 Tz
0.004 Tc
( móg) Tj
0.000 Tc
(ł) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
33.480 228.960 Td
0.000 Tw
97.046 Tz
/F48 7.700 Tf
0 Ts
-0.134 Tc
(F) Tj
0.000 Tc
(]) Tj
5.728 Tw
90.000 Tz
0.034 Tc
( administracj) Tj
0.000 Tc
(i) Tj
1.992 Tw
-0.116 Tc
( dom) Tj
0.000 Tc
(u) Tj
107.782 Tw
94.927 Tz
-0.642 Tc
( '—) Tj
0.000 Tc
(') Tj
2.044 Tw
97.046 Tz
-0.134 Tc
( lu) Tj
0.000 Tc
(b) Tj
0.024 Tw
-0.134 Tc
( ni) Tj
0.000 Tc
(e) Tj
0.248 Tw
90.000 Tz
0.064 Tc
( chcia) Tj
0.000 Tc
(ł) Tj
0.287 Tw
0.078 Tc
( potwierdzi) Tj
0.000 Tc
(ć) Tj
0.368 Tw
89.347 Tz
-0.021 Tc
( odbior) Tj
0.000 Tc
(u) Tj
-0.620 Tw
90.000 Tz
0.223 Tc
( przesyłk) Tj
0.000 Tc
(i) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
165.960 198.720 Td
0.000 Tw
90.868 Tz
/F48 7.700 Tf
0 Ts
-0.006 Tc
(\(czytelni) Tj
0.000 Tc
(e) Tj
1.164 Tw
95.196 Tz
-0.249 Tc
( imi) Tj
0.000 Tc
(ę) Tj
0.293 Tw
105.675 Tz
( i) Tj
0.461 Tw
90.000 Tz
0.083 Tc
( nazwisk) Tj
0.000 Tc
(o) Tj
2.272 Tw
-0.115 Tc
( odbiorcy) Tj
0.000 Tc
(\)) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
27.720 182.520 Td
0.000 Tw
87.009 Tz
/F48 7.700 Tf
0 Ts
-0.047 Tc
(2) Tj
0.000 Tc
(\)) Tj
10.264 Tw
90.000 Tz
0.152 Tc
( Przesyłk) Tj
0.000 Tc
(i) Tj
0.327 Tw
89.056 Tz
-0.047 Tc
( ni) Tj
0.000 Tc
(e) Tj
1.114 Tw
90.000 Tz
-0.061 Tc
( doręczon) Tj
0.000 Tc
(o) Tj
1.840 Tw
89.056 Tz
( w) Tj
1.104 Tw
90.000 Tz
0.016 Tc
( sposó) Tj
0.000 Tc
(b) Tj
1.349 Tw
-0.064 Tc
( określon) Tj
0.000 Tc
(y) Tj
2.148 Tw
89.056 Tz
( w) Tj
1.198 Tw
-0.047 Tc
( pk) Tj
0.000 Tc
(t) Tj
2.034 Tw
84.385 Tz
-0.499 Tc
( 1) Tj
0.000 Tc
(.) Tj
0.562 Tw
90.000 Tz
0.078 Tc
( przesyłk) Tj
0.000 Tc
(ę) Tj
0.890 Tw
0.077 Tc
( pozostawion) Tj
0.000 Tc
(o) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
61.560 165.600 Td
0.000 Tw
85.779 Tz
/F48 7.700 Tf
0 Ts
-0.681 Tc
(l—) Tj
0.000 Tc
(l) Tj
4.585 Tw
94.121 Tz
( w) Tj
1.198 Tw
90.000 Tz
0.010 Tc
( placówc) Tj
0.000 Tc
(e) Tj
1.323 Tw
0.087 Tc
( pocztowe) Tj
0.000 Tc
(j) Tj
64.457 Tw
94.121 Tz
( l) Tj
5.600 Tw
( l) Tj
2.157 Tw
( w) Tj
3.016 Tw
96.219 Tz
-0.131 Tc
( urzędzi) Tj
0.000 Tc
(e) Tj
0.809 Tw
90.000 Tz
-0.059 Tc
( gmin) Tj
0.000 Tc
(y) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
160.200 140.040 Td
0.000 Tw
94.854 Tz
/F48 7.700 Tf
0 Ts
-0.070 Tc
(\(nazw) Tj
0.000 Tc
(a) Tj
1.051 Tw
89.720 Tz
0.105 Tc
( placówk) Tj
0.000 Tc
(i) Tj
0.863 Tw
90.000 Tz
0.005 Tc
( pocztowe) Tj
0.000 Tc
(j) Tj
0.943 Tw
91.970 Tz
-0.056 Tc
( lu) Tj
0.000 Tc
(b) Tj
1.057 Tw
90.000 Tz
-0.200 Tc
( urzęd) Tj
0.000 Tc
(u) Tj
1.273 Tw
0.131 Tc
( gminy) Tj
0.000 Tc
(\)) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
45.360 131.760 Td
0.000 Tw
93.506 Tz
/F48 7.700 Tf
0 Ts
0.000 Tc
(o) Tj
0.681 Tw
90.000 Tz
-0.019 Tc
( czy) Tj
0.000 Tc
(m) Tj
1.752 Tw
94.528 Tz
-0.038 Tc
( umieszczon) Tj
0.000 Tc
(o) Tj
0.491 Tw
93.095 Tz
0.086 Tc
( zawiadomienia) Tj
0.000 Tc
(:) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
33.120 120.240 Td
0.000 Tw
106.195 Tz
/F48 7.700 Tf
0 Ts
0.000 Tc
(l) Tj
5.110 Tw
( l) Tj
2.359 Tw
93.028 Tz
( w) Tj
0.746 Tw
90.000 Tz
0.130 Tc
( drzwiac) Tj
0.000 Tc
(h) Tj
0.742 Tw
0.115 Tc
( adresat) Tj
0.000 Tc
(a) Tj
21.443 Tw
106.195 Tz
( l) Tj
4.556 Tw
( l) Tj
1.198 Tw
93.028 Tz
( w) Tj
0.753 Tw
90.000 Tz
0.123 Tc
( oddawcze) Tj
0.000 Tc
(j) Tj
1.274 Tw
0.018 Tc
( skrzync) Tj
0.000 Tc
(e) Tj
1.207 Tw
0.049 Tc
( pocztowe) Tj
0.000 Tc
(j) Tj
12.274 Tw
85.911 Tz
-1.091 Tc
( [~~) Tj
0.000 Tc
(|) Tj
3.306 Tw
93.028 Tz
( w) Tj
0.837 Tw
90.000 Tz
0.039 Tc
( skrytc) Tj
0.000 Tc
(e) Tj
0.714 Tw
0.145 Tc
( pocztowe) Tj
0.000 Tc
(j) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
28.080 102.960 Td
0.000 Tw
67.627 Tz
/F48 7.700 Tf
0 Ts
0.562 Tc
(3) Tj
0.000 Tc
(1) Tj
9.619 Tw
90.000 Tz
0.254 Tc
( Przesyłk) Tj
0.000 Tc
(i) Tj
-0.231 Tw
86.505 Tz
0.139 Tc
( ni) Tj
0.000 Tc
(e) Tj
0.978 Tw
93.823 Tz
-0.100 Tc
( doręczono) Tj
0.000 Tc
(,) Tj
0.389 Tw
88.468 Tz
0.207 Tc
( gdy) Tj
0.000 Tc
(ż) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
33.480 88.560 Td
0.000 Tw
104.499 Tz
/F48 7.700 Tf
0 Ts
-0.796 Tc
(i—) Tj
0.000 Tc
(i) Tj
2.085 Tw
90.000 Tz
0.295 Tc
( adresa) Tj
0.000 Tc
(t) Tj
-0.819 Tw
86.714 Tz
0.178 Tc
( odmówi) Tj
0.000 Tc
(ł) Tj
1.489 Tw
90.000 Tz
0.066 Tc
( przyjęci) Tj
0.000 Tc
(a) Tj
16.673 Tw
104.499 Tz
-0.796 Tc
( i—) Tj
0.000 Tc
(i) Tj
-0.299 Tw
90.000 Tz
0.279 Tc
( adresa) Tj
0.000 Tc
(t) Tj
-0.185 Tw
90.825 Tz
-0.017 Tc
( ni) Tj
0.000 Tc
(e) Tj
0.913 Tw
79.793 Tz
0.204 Tc
( podją) Tj
0.000 Tc
(ł) Tj
1.670 Tw
87.672 Tz
0.202 Tc
( przesyłk) Tj
0.000 Tc
(i) Tj
0.212 Tw
90.825 Tz
( z) Tj
1.253 Tw
90.000 Tz
0.116 Tc
( placówk) Tj
0.000 Tc
(i) Tj
0.613 Tw
86.413 Tz
0.184 Tc
( pocztowej/urzęd) Tj
0.000 Tc
(u) Tj
0.931 Tw
90.000 Tz
0.041 Tc
( gmin) Tj
0.000 Tc
(y) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
33.480 72.000 Td
0.000 Tw
94.033 Tz
/F48 7.700 Tf
0 Ts
-0.844 Tc
([—) Tj
0.000 Tc
(i) Tj
2.365 Tw
90.000 Tz
0.078 Tc
( niedostateczn) Tj
0.000 Tc
(y) Tj
1.681 Tw
0.034 Tc
( adre) Tj
0.000 Tc
(s) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
40.680 54.720 Td
0.000 Tw
89.760 Tz
/F48 7.700 Tf
0 Ts
0.000 Tc
(z) Tj
1.632 Tw
90.000 Tz
-0.020 Tc
( innyc) Tj
0.000 Tc
(h) Tj
1.060 Tw
0.208 Tc
( przyczy) Tj
0.000 Tc
(n) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
185.400 45.720 Td
0.000 Tw
92.653 Tz
/F48 7.700 Tf
0 Ts
-0.130 Tc
({poda) Tj
0.000 Tc
(ć) Tj
-0.169 Tw
95.937 Tz
-0.017 Tc
( jakie) Tj
0.000 Tc
(\)) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
43.920 29.880 Td
0.000 Tw
111.139 Tz
/F48 7.700 Tf
0 Ts
-0.702 Tc
([~) Tj
0.000 Tc
(]) Tj
6.191 Tw
90.000 Tz
0.207 Tc
( Zaznaczy) Tj
0.000 Tc
(ć) Tj
1.579 Tw
0.396 Tc
( właściw) Tj
0.000 Tc
(y) Tj
-0.593 Tw
0.141 Tc
( kwadrat) Tj
0.000 Tc
(.) Tj
ET
BT
3 Tr
0.000 0.000 0.000 rg
257.400 12.600 Td
0.000 Tw
90.000 Tz
/F48 7.700 Tf
0 Ts
-0.154 Tc
(\(dat) Tj
0.000 Tc
(a) Tj
-0.091 Tw
159.292 Tz
( i) Tj
-0.383 Tw
90.000 Tz
-0.119 Tc
( podpi) Tj
0.000 Tc
(s) Tj
1.639 Tw
86.594 Tz
0.203 Tc
( doręczającego/wydającego) Tj
0.000 Tc
(\)) Tj
ET

When I use StringRegExp() function with that params:

Local $a1 = StringRegExp(ClipGet(), '(?s)(?(?=Td\R\[\()Td\R\[\((.*?)\] Tj|Tc\R\((.*?)\) Tj)',3)
_ArrayDisplay($a1 ,'$a1')
Local $a2 = StringRegExp(ClipGet(), 'Tc\R\((.*?)\) Tj',3)
_ArrayDisplay($a2 ,'$a2')

why I get two diffrent results, 

specifying
why the first table contains additional empty elements


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites



In the first regexp, the pattern requires the character sequence '[(' which is nowhere in your input file, hence the TRUE branch of the condition is never taken. But the capturing group is still populated (with an empty string).

To convince yourself, try this, the difference being that the previous first capturing group is now non-capturing:

Local $a1 = StringRegExp(ClipGet(), '(?s)(?(?=Td\R\[\()Td\R\[\((?:.*?)\] Tj|Tc\R\((.*?)\) Tj)',3)
_ArrayDisplay($a1 ,'$a1')

Is this point clearer?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Thank you.
Your answer (very helpful) occurred to me more questions.

For now, I'm looking for answers in the documentation and tutorials like this:

http://www.rexegg.com/regex-conditionals.html

Br.

mLipok


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

The numbering of capturing groups is basically fairly simple: each pair of parenthesis used for defining capturing groups is numbered sequentially from 1 and from left to right.

In practice, things are a little more complex: the (?| alt1 | alt2 | ... | altn) sequence reuses the numbering sequence assigned within the alt1 leftmost alternation into the other alternations alt2to altn.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0