I am trying to create a regex for getting legislation references in pt-br like:
- Lei 11.738/2008
- Lei nº 9.394/96
- Lei Estadual nº 6.834
- Lei 5.539/2009
- Decreto 30.825/2002
- Lei 1614 de 21 de janeiro de 1990
- art. 1.039 do CPC/2015
ps.: lei (law), decreto (decree) and cpc (civil procedure code)
My current attempt is:
(?<LEGISLACAO>(art(\.|igos?)\s[\d\.º]+(,\s*?(caput|§),\s*?)?\s+?d[oa]\s+?)*?((lei(\s(estadual|nacional|federal))??|decreto|N?CPC)\s*?(n[º\.])*?\s*?[\d\.\/º]+)(\s*?de\s*?\d{1,2}\s*?de\s*(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)\s*?de\s*?\d{2,4})?)
Regex101: https://regex101.com/r/69ggnm/1
But this regex still have some flaws and is capturing some undesired strings like:
- lei nº.
- lei.
- CPC.
And is also getting the "period" in the end of some citations like:
- LEI FEDERAL Nº 11.738/2008.
And it is not getting these ones:
- lei nº. 1.060/50
- art.334, § 5º do CPC
- artigo 85, §11º, do CPC
How could be a regex to avoid those problems and still getting the correct results?