preg-match

Using PHP DOM want to show all string as a output

邮差的信 提交于 2020-01-15 09:41:09
问题 Here, is my html string in $data variable in php, and that string have some text like <140/90 mmHg OR <130/80 mmHg this line not showing when i run this code using PHP DOMDocument because when coming less-than & grater-than signs its problematic. <?php $data = 'THE CORRECT ANSWER IS C. <p>Choice A Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s</p> <p></p> <p>Choice B Lorem Ipsum is simply

How to replace all ul and li tag with div using PHP Simple HTML DOM Parser?

☆樱花仙子☆ 提交于 2020-01-15 03:30:08
问题 Ok, I want to create a "website mobilizer" by using PHP Simple HTML DOM Parser. In the present phase, I want to- change all 'ul' and 'li' tag to 'div' tag and change all 'table' elements (e.g. table,tr,td,th) to div. I tried an workaround for the first problem in following way: . $html=new new simple_html_dom(); $html>load_file($sourceurl); $div="div"; foreach ($html->find('ul') as $element) { $element=$div; } It does seem dull, but I'm not being able to find any other solution. I am

preg_match or operator

旧时模样 提交于 2020-01-14 10:46:28
问题 My code below produces an error, unknown modified "|"... I'm trying to use it as the OR operator. What is the correct way to run this code without error? $p = "(\w+)|(\()|(\))|(\,)"; $s = "sum(blue,paper,green(yellow,4,toast)))"; preg_match($p,$s, $matches); print_r($matches); Edit Okay I changed it a bit... ~(\w+|\(|\)|,)~ Now... here's the problem: I need to take that string and split it into an array like this: array("sum","(","blue","paper","green","(" ... etc ); Can someone help me do

preg_match() No ending deliminator found

ぃ、小莉子 提交于 2020-01-14 05:22:13
问题 I have read this and this, and this, and half a dozen other questions about preg_match on SO, and I still can't figure this one out. I went to use this code from a CodeReview question and got an error saying that there was a preg_match() no deliminator '/' found. Can someone help me fix it? The code in question is this statement: if (preg_match($regex, $user_agent)) { You can find it by going to the bottom of the new, edited version of the code in the question itself, and counting up approx

PHP Regex to match the last occurrence of a string

时光总嘲笑我的痴心妄想 提交于 2020-01-13 13:11:06
问题 My string is $text1 = 'A373R12345' I want to find last none digital number occurrence of this string. So I use this regular expression ^(.*)[^0-9]([^-]*) Then I got this result: 1.A373 2.12345 But my expected result is: 1.A373R (It has 'R') 2.12345 Another example is $text1 = 'A373R+12345' Then I got this result: 1.A373R 2.12345 But my expected result is: 1.A373R+ (It has '+') 2.12345 I want contain the last none digital number!! Please help !! thanks!! 回答1: $text1 = 'A373R12345'; preg_match(

preg_match() and username

萝らか妹 提交于 2020-01-12 01:50:13
问题 function isUserID($username) { if (preg_match('/^[a-z\d_]{2,20}$/i', $username)) { return true; } else { return false; } } Easy one.., i have this, can you explain what it checks for? I know it checks if the username have length between 2-20, what more? Thanks 回答1: It searches for text containing only alphanumeric and underscore characters, from 2 to 20 characters long. /^[a-z\d_]{2,20}$/i |||| | ||| ||| |||| | ||| ||i : case insensitive |||| | ||| |/ : end of regex |||| | ||| $ : end of text

preg_match() expects parameter 2 to be string, array Given not working [duplicate]

情到浓时终转凉″ 提交于 2020-01-11 14:56:10
问题 This question already has answers here : Reference - What does this error mean in PHP? (36 answers) Closed 28 days ago . <?php $a="https://sayat.me/chitmarike"; $html=file_get_contents("$a"); $headers = get_headers($a); preg_match('~id="bar" value="([^"]*)"~', $html, $img); $img1 = $img[1]; echo $img1; preg_match('/(?<=csam=).*?(?=;)/', $headers, $cook); $cook1 = $cook[1]; echo $cook1; ?> I want to extract the value of csam from the cookie header. This is what it looks like: Array ( [0] =>

preg_match() expects parameter 2 to be string, array Given not working [duplicate]

隐身守侯 提交于 2020-01-11 14:56:07
问题 This question already has answers here : Reference - What does this error mean in PHP? (36 answers) Closed 28 days ago . <?php $a="https://sayat.me/chitmarike"; $html=file_get_contents("$a"); $headers = get_headers($a); preg_match('~id="bar" value="([^"]*)"~', $html, $img); $img1 = $img[1]; echo $img1; preg_match('/(?<=csam=).*?(?=;)/', $headers, $cook); $cook1 = $cook[1]; echo $cook1; ?> I want to extract the value of csam from the cookie header. This is what it looks like: Array ( [0] =>

How to find a URL from a content by PHP?

南笙酒味 提交于 2020-01-11 11:58:12
问题 need a simply preg_match, which will find "c.aspx" (without quotes) in the content if it finds, it will return the whole url. As a example $content = '<div>[4]<a href="/m/c.aspx?mt=01_9310ba801f1255e02e411d8a7ed53ef95235165ee4fb0226f9644d439c11039f%7c8acc31aea5ad3998&n=783622212">New message</a><br/>'; now it should preg_match "c.aspx" from $content and will give a output as "/m/c.aspx?mt=01_9310ba801f1255e02e411d8a7ed53ef95235165ee4fb0226f9644d439c11039f%7c8acc31aea5ad3998&n=783622212" The

How to find a URL from a content by PHP?

情到浓时终转凉″ 提交于 2020-01-11 11:58:10
问题 need a simply preg_match, which will find "c.aspx" (without quotes) in the content if it finds, it will return the whole url. As a example $content = '<div>[4]<a href="/m/c.aspx?mt=01_9310ba801f1255e02e411d8a7ed53ef95235165ee4fb0226f9644d439c11039f%7c8acc31aea5ad3998&n=783622212">New message</a><br/>'; now it should preg_match "c.aspx" from $content and will give a output as "/m/c.aspx?mt=01_9310ba801f1255e02e411d8a7ed53ef95235165ee4fb0226f9644d439c11039f%7c8acc31aea5ad3998&n=783622212" The