regex - Removing white space from the beginning using regular expression in PHP -
i'm trying data website using php curl. output, need neglect white spaces , empty lines. used regex. i'm not familiar regex.
please me solve problem.
there code:
if(preg_match('/<div class="search-results-details-body">(.*?) <div class="search-results-details-footer">/s', $result, $output)) { $stripped_result = ltrim(strip_tags($output[1])); $refined_output = str_replace(' ','',$stripped_result); $regex = preg_replace('[\n\n]', "\n", $refined_output); exit(); }
and output in order:
requirements minimum 2 years of web development experience required experience php, mysql, html, css, , javascript preferred bachelors degree in computer science or related field full knowledge , experience of software development lifecycle strong organisational , analytical skills ability work under pressure meet deadlines , required quality standards ability multi-task , prioritize responsibilities excellent oral , written communication skills
here want remove starting white spaces. need output :
requirements minimum 2 years of web development experience required experience php, mysql, html, css, , javascript preferred bachelors degree in computer science or related field full knowledge , experience of software development lifecycle strong organisational , analytical skills ability work under pressure meet deadlines , required quality standards ability multi-task , prioritize responsibilities excellent oral , written communication skills
please suggest solution
thank you
i want remove starting white spaces, need neglect white spaces , empty lines.
just replace empty string
^\s+
here online demo
^
matches start of line/string\s
matches white space character[\r\n\t\f ]
sample code:
$re = "/^\\s+/m"; $result = preg_replace($re, '', $str);
Comments
Post a Comment