I want to check posted content against a pattern. I am having trouble setting up this preg_match (or array?). The pattern being…
TEXTHERE:TEXTHERE
TEST:TEST
FILE:FILE
AND
TEXTHERE:TEXTHERE TEST:TEST FILE:FILE
I want to check for either pattern, the one with the whitespace and the one with the line break. If the posted content is this… (with extra line breaks and/or whitespace)
TEXTHERE:TEXTHERE
TEST:TEST
FILE:FILE
I want it to somehow display as…
TEXTHERE:TEXTHERE
TEST:TEST
FILE:FILE
and still match against the pattern.
I want it to still work, somehow by stripping the extra line break/and or extra white space…
$loader = file_get_contents( 'temp/load-'.$list.'.php' );
If it doesn’t follow the string pattern, I want it to output an error message, etc.
if($loader == ???) { // done
} else { // error
}
Try something like this:
Output:
You’ll get the same output for:
You first check if it matches:
And if it matches the above, you replace 2 or more successive white space chars
\s{2,}with a single line break.Of course, you may need to adjust
[A-Z]+to something else.