Answer the question
In order to leave comments, you need to log in
How to increase the maximum number of backreferences in regular expressions (sed)?
The crux of the matter is this, there is a long and nasty regular expression I wrote to parse a database of addresses:
s/"([0-9]*)";"((г\. )*(([^ ]*))(( обл\.)|( АО\.)|( Респ\.))*)(, )*((.*) р-н)*(, )*((п\/о\.) ([^,]*))*(, )*(((д\.)|(ж\/д_рзд\.)|(рп\.)|(ж\/д_ст\.)|(ст\.)|(высел\.)|(х\.)|(казарма\.)|(м\.)|(жилрайон\.)|(нп\.)|(снт\.)|(г\.)|(дп\.)|(снт\.)|(п\.)|(пст\.)|(п\/ст\.)|(пгт\.)|(п\/гт\.)|(с\.)|(тер\.)|(массив\.))( [^,]*))*(, )*(((д\.)|(ж\/д_рзд\.)(снт\.)|(г\.)|(дп\.)|(нп\.)|(мкр\.)|(жилзона\.)|(снт\.)|(п\.)|(пст\.)|(п\/ст\.)|(пгт\.)|(п\/гт\.)|(с\.)|(тер\.)|(массив\.))( [^,]*))*(, )*((.* )((ул\.)|(пер\.)|(наб\.)|(ш\.)|(линия\.)|(казарма\.)|(б-р\.)|(тер\.)|(уч-к\.)|(пр-кт\.)|(сад\.)|(остров\.)|(канал\.)|(дор\.)|(км\.)|(городок\.)|(тракт\.)|(гск\.)|(просек\.)|(переезд\.)|(заезд\.)|(парк\.)|(площадь)|(проезд\.)|(туп\.)|(м\.)|(проток\.)|(ст\.)|(вал\.)|(п\.)|(спуск\.)|(пл-ка\.)|(д\.)|(коса\.)|(п\/ст\.)|(пр\.)|(пл\.)|(мкр\.)|(аллея\.)|(кв-л\.)|(ж\/д_будка\.)|(х\.)|(рзд\.)|(тск\.)|(сквер\.)|(стр\.)|(снт\.)|(мост\.)|(метро\.)))*(, )*";"([0-9]*)";"(((д\.)|(ая\.)|(нетр\.)|(д\.)|(а\\я\.)|(а\/я\.))*(([0-9Х]*[-\\\/0-9]*)([\\\/-]([А-Яа-я])*)*))*([^"]*)";"(([0-9]*)([А-Яа-я]*))*"/"\2";"\68";"69";"120";"130"/
Answer the question
In order to leave comments, you need to log in
Do NOT use regular expressions.
Each tool has its purpose, and regular expressions were a tool to help parse, not the parser itself.
You can use something else instead of SED, where more backreferences are supported. But it's better to rewrite it in pearl or python.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question