Regular Expressions 101

Community Patterns

Sanitize CSV Export Expression for regex.replace (this regex) with empty string

0

Regular Expression
.NET 7.0 (C#)

@"
[^0-9a-zA-Z|\\/ !#$%^&*()[{}\]:<>?_\\]+
"
gm

Description

see owasp recommendation for things to remove from a csv export.

this expression matches on following characters [. , ; + = - @ ' "] also carriage return

make sure to clear strings for whitespace and choose your preferred methods for additional security from the examples in the owasp documentation

https://owasp.org/www-community/attacks/CSV_Injection

Submitted by anonymous - 2 years ago