php - Issues with greediness in regex -


in php, i'm matching text here http://siba.thenetworksolution.it/allegati/h3018500d7fdde9aca05671f49f4f3746a69daf96.1329514.pdf.txt following regex:

preg_match('#(.*(?s))(particella |particelle |p\.|part\.|p |part |mappale |mapp\.|mapp |n\.|\*)\s*(\d+[\d /\p{pd}]*)($|.{0,20}(?s)(graffati|particella |particelle |p\.|.*part\.|p |part |mappale |mapp\.|mapp |n\.|subalterno |subalterni |sub\.|s\.|sub |s |\bcat\b|\bcategoria\b|\brendita\b|\bvani\b|\bconsistenza\b|\br\.c\.\b))#i', $txt, $matches, preg_offset_capture, $offset) 

with offset = 1155 (that offset of word "foglio" in text).

i expected them match 454 (that after offset) matches 57/1998 instead (that many rows after).

after tests on regex101.com discovered issue carriage return between prefix particella , 454, expected \s match line feeds.

how can correct greediness regex match 454?

solved. there space after particella in second group.


Comments

Popular posts from this blog

ios - UITEXTFIELD InputView Uipicker not working in swift -

Hatching array of circles in AutoCAD using c# -