i am using the following regex to check input for anyting other then the allowed characters...(a-zA-z0-9 a dot, comma, dash and a singlequote and the br tag)
<?php
$regex_char_appearance = '/([A-Za-z0-9 \-\.\,\']|(<br>))/';
?>
I have been trying to create a regex to clean user input. I just can't get it to work so tried different things like...
<?php
$regex_char_appearance = '/(?!<br>)([^A-Za-z0-9 \-\.\,\'])/';
$regex_char_appearance = '/([^A-Za-z0-9 \-\.\,\']|[^(<br>)])/';
//remove anything other then alphabetic and allowed
$post_char_appearance = preg_replace( $regex_char_appearance , '' , $post_char_appearance);
?>
so the goal is to remove anything other then a-zA-z0-9, a dot, comma, dash , singlequote and the br tag for output with preg_replace.
Can someone help me put a regex together that works?
` doing here? You want to match anything other than `
`? – Wiktor Stribiżew Apr 20 '16 at 08:19
is allowed as well....but not < or >. – Joe Boss Apr 20 '16 at 08:25
tag... – Joe Boss Apr 20 '16 at 08:35
)|[^A-Za-z0-9.,'-]~' , '$1' , $post_char_appearance);` - [demo](https://regex101.com/r/yJ0yU8/2) – Wiktor Stribiżew Apr 20 '16 at 08:38
intact...thanks for the demo...usefull! – Joe Boss Apr 20 '16 at 08:57
` are reinserted back into string while `preg_replace`ing. – Wiktor Stribiżew Apr 20 '16 at 08:58