So I just want to make sure I've wrapped my head around this correctly, if I'm wrong or perhaps not understanding something to it's fullest potential please let me know!
if (!preg_match('/^[0-9]+$/', $ADD) || !preg_match('/^[a-zA-Z]+$/i', $ADD) {
array_push($errors, " Invalid address.");
}
$ADD = preg_replace("/^[a-zA-z0-9\s-#\/]+$/i", "", $ADD);
So:
- ^ = Match the expression from the start of the string ...
- $ = ... to the end of the string
- + = Look for one or more instance of this. (Does this mean there HAS to be one or more instance?)
- /i = This is case sensitive search. In theory if i'm using this, do I really need to check for a-zA-z or could I just use /a-z/i ?
- \s = This checks for any amount of white spaces.
Do I even need to add in ^ and $ to check the entire string start to fin, or will it just do so without ^$ included?