A simple PHP Regex line starts with

I am looking for a regex for stet if a line starts on another line. It must be RegEx, and it must be a PHP regular expression.

Any help appreciated. Thanks Relations

+4
source share
1 answer
$result = preg_match("#^startText(.*)$#i", $string); if($result == 0) { echo "No match"; } else { echo "Match found."; } 

PHP.net regular expressions

preg_match returns either 0 for matches found, or 1 , because preg_match stops at the first match. If you want to read all matches, use preg_match_all .

Check out the PHP site if you have more problems.

+9
source

All Articles