Sep-15-2017, 07:10 AM
You will see three snippets, first a part of my Python-code, second a part of the text the Python works on and third some printed results. Then I describe my problem
<snippet>
else:
print('Tak1')
RegString = Rol + r'[:]?' + '[ \t\n]*' + RuweNaam + '[\n\t ]*' + '([A-z]*[:]?[\n\t ]*[A-z, ]*\n)*' + 'Rol[:]?' + '[\n\t ]*' + '(?P<R>[A-Z][a-z]*[ ]?)*\n'
# Hoe vind je de waarde in content
# print(RegString)
Reg = re.compile( RegString )
# print(Reg)
Match = Reg.search( content )
print(Match)
Role = Match.group('R').strip()
print(Role)
#
<\snippet>
<snippet>
Personen
Naam: Mulmaker, Helena
Rol: Getuige
Naam: Lutke, Dorothea
Geslacht: v
Rol: Moeder
Naam: Mulmaker, David
Geslacht: m
Rol: Vader
<\snippet>
Some results from print:
<snippet>
<_sre.SRE_Match object; span=(159, 398), match='Naam: \tMulmaker, Helena\nRol: \tGetuige\n\nNaam:>
<\snippet>
<snippet>
<_sre.SRE_Match object; span=(198, 398), match='Naam: \tLutke, Dorothea\nGeslacht: \tv\nRol: \tMo>
<\snippet>
Problem:
As you can see the match cuts off after a certain length has reached, but in the search a longer match is expected. I hope that the maximum length a match can be made longer.
Questions:
Can this maximum length been set?
Or is it a system-value that cannot been changed by users?
If so, do you have suggestions to bypass this problem?
Thanks, Maashoeven
<snippet>
else:
print('Tak1')
RegString = Rol + r'[:]?' + '[ \t\n]*' + RuweNaam + '[\n\t ]*' + '([A-z]*[:]?[\n\t ]*[A-z, ]*\n)*' + 'Rol[:]?' + '[\n\t ]*' + '(?P<R>[A-Z][a-z]*[ ]?)*\n'
# Hoe vind je de waarde in content
# print(RegString)
Reg = re.compile( RegString )
# print(Reg)
Match = Reg.search( content )
print(Match)
Role = Match.group('R').strip()
print(Role)
#
<\snippet>
<snippet>
Personen
Naam: Mulmaker, Helena
Rol: Getuige
Naam: Lutke, Dorothea
Geslacht: v
Rol: Moeder
Naam: Mulmaker, David
Geslacht: m
Rol: Vader
<\snippet>
Some results from print:
<snippet>
<_sre.SRE_Match object; span=(159, 398), match='Naam: \tMulmaker, Helena\nRol: \tGetuige\n\nNaam:>
<\snippet>
<snippet>
<_sre.SRE_Match object; span=(198, 398), match='Naam: \tLutke, Dorothea\nGeslacht: \tv\nRol: \tMo>
<\snippet>
Problem:
As you can see the match cuts off after a certain length has reached, but in the search a longer match is expected. I hope that the maximum length a match can be made longer.
Questions:
Can this maximum length been set?
Or is it a system-value that cannot been changed by users?
If so, do you have suggestions to bypass this problem?
Thanks, Maashoeven