I'm trying to check for new lines a string using:
Code: Select all
if(preg_match("/(%0A|%0D|\\n+|\\r+)/i", $string)) {
echo "do something";
}Thanks in advance.
Moderator: General Moderators
Code: Select all
if(preg_match("/(%0A|%0D|\\n+|\\r+)/i", $string)) {
echo "do something";
}Code: Select all
if(preg_match("~[\n\r]~", $string))Code: Select all
$string = 'New
Line';
for($i=0;$i<strlen($string);$i++) echo "{{$string[$i]}}" . ord($string[$i]) . " <br />\n";
Code: Select all
if(preg_match("~[\n\r\x0a\x0d]~", $string))Code: Select all
$string = 'new\nline';
{n}110
{e}101
{w}119
{\}92
{n}110
{l}108
{i}105
{n}110
{e}101Code: Select all
$regex=',[\n\r\x0a\x0d]|\\\n,';Code: Select all
$regex=',\\\n,';Code: Select all
<?php
$regex=',\\\n,';
$string='new\nline';
echo preg_match($regex,$string);
?>No idea... that really depends on what you're expecting malicious code to look like---it's a security question. (btw I just noticed there's a security board.)should I also be looking for the actual new line also?