import re
regex = re.compile(r"(\r|\n| |\t)+\<Grid(\r|\n| |\t)+Grid\.Row=\"0\"(\r|\n| |\t)+IsVisible=\"False\"(\r|\n| |\t)+Style=\"\{StaticResource(\r|\n| |\t)+MadressahFilterPickerGridBackgroundStyle\}\"\>")
test_str = (" <Grid Grid.Row=\"2\" Grid.Column=\"2\" RowSpacing=\"0\">\n"
" <Grid.RowDefinitions>\n"
" <RowDefinition Height=\"Auto\" />\n"
" </Grid.RowDefinitions>\n"
" <Grid Grid.Row=\"0\" Style=\"{StaticResource MadressahFilterPickerGridBackgroundStyle}\">\n"
" <StackLayout Orientation=\"Horizontal\">\n"
" <StackLayout.GestureRecognizers>\n"
" <TapGestureRecognizer Tapped=\"ParentTapGestureRecognizer_Tapped\" />\n"
" </StackLayout.GestureRecognizers>\n"
" <Label x:Name=\"parentName\" Text=\"{Binding ParentPicker}\"\n"
" BindingContext=\"{ Binding Source={x:Reference Root}, Path=BindingContext}\"\n"
" Style=\"{StaticResource MadressahFilterPickerLabelStyle}\" LineBreakMode=\"NoWrap\"/>\n"
" <Label Style=\"{StaticResource MadressahPickerArrowStyle}\" />\n"
" </StackLayout>\n"
" </Grid>\n"
" <Grid Grid.Row=\"0\" IsVisible=\"False\"\n"
" Style=\"{StaticResource MadressahFilterPickerGridBackgroundStyle}\">\n"
" <Picker x:Name=\"parentList\" Title=\"{i18n:Translate selectparent}\"\n"
" ItemsSource=\"{Binding ParentList}\"\n"
" ItemDisplayBinding=\"{Binding FullName}\"\n"
" SelectedItem=\"{Binding ParentSelected}\"\n"
" BindingContext=\"{ Binding Source={x:Reference Root}, Path=BindingContext}\" />\n"
" </Grid>\n"
" </Grid>")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html