RegEx for censoring multi-line texts

9 views
Skip to first unread message

Miroslav (Code for Croatia, ImamoPravoZnati.org)

unread,
Aug 18, 2021, 5:33:56 AM8/18/21
to Alaveteli Dev
Hello,
Do somebody have experience with Alaveteli requests censoring regex via Admin GUI?

I'm trying to censor multi-line text but it's not applying as expected.

For example, text that should be redacted:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur
vulputate sed lorem quis volutpat. Cras sit amet blandit quam, eget
lobortis enim. Vivamus sed condimentum quam, tincidunt feugiat mi.
Quisque ut pulvinar lectus. Suspendisse feugiat elit sollicitudin nunc
mattis feugiat. Ut vitae arcu ligula. Donec nec rhoncus nisi.

I tried this regex, but but with no luck:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur\nvulputate sed lorem quis volutpat. Cras sit amet blandit quam, eget\nlobortis enim. Vivamus sed condimentum quam, tincidunt feugiat mi.\nQuisque ut pulvinar lectus. Suspendisse feugiat elit sollicitudin nunc\nmattis feugiat. Ut vitae arcu ligula. Donec nec rhoncus nisi.

Tried to validate my regex via https://rubular.com/:
it should work based on this - https://rubular.com/r/vvDEEPFVaHCj87

Any ideas or examples how did you successfully managed to apply regex censor rules for multi-line texts?

Thanks,
Miroslav



Miroslav (Code for Croatia, ImamoPravoZnati.org)

unread,
Aug 18, 2021, 5:44:50 AM8/18/21
to Alaveteli Dev
Hello,
Actually I found correct syntax for new line is (\s+|\n) which works perfect!

Corrected example (that also works on Alaveteli censor rules):

Cheers,
Miroslav

Gareth Rees

unread,
Aug 19, 2021, 9:33:02 AM8/19/21
to Alaveteli Dev
Hey Miroslav,

Glad you figured this out.

We do set the multiline option [1], which makes "." also match newlines [2], so you could make this a little shorter regexp [3].

Best,

Gareth

Reply all
Reply to author
Forward
0 new messages