how to match rtmp links [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How to match the following link structure that started with rtmp://
$link = "rtmp://00.000.000.000/live"; // GOOD
$link = "http://00.000.000.000/live"; // BAD
$link = "www.00.000.000.000/live"; // BAD
so only matching the links with rtmp with preg_match or whatever ~ thanks

I'd do:
preg_match('~^rtmp://~', $link);

Something like this will suffice..
if(stripos($link,'rtmp://')!==false)
{
echo "Good";
}

Related

Select text on a string after X symbol [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
i have this string
$string = "Social\Notify\Models\User";
How can i tell to php how select just the fourth segment of it? in this case just the word User?
Something like this will do?
$str='Social\Notify\Models\User';
echo explode('\\',$str)[3]; //"prints" User

Find specific string from response in php [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am getting following response
{"success":true,"error":false,"code":"SJKUT3GR"}
I just want to print SJKUT3GR from above.
anyone knows how to do this?
$data = json_decode($response);
echo $data->code;

JavaScript regex and replace like PHP preg_replace [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have following code in php:
$link ='mylink';
$description = '<p><img src="http://l3.yimg.com/bt/api/res/1.2/hmYETKsJS2CXBsG7oO125w--/YXBwaWQ9eW5ld3M7Zmk9ZmlsbDtoPTg2O3E9ODU7dz0xMzA-/http://media.zenfs.com/en_us/News/Reuters/2013-09-07T045234Z_3_CBRE9851BPL00_RTROPTP_2_RUSSIA-G20.JPG">By Roberta Rampton and Susan Cornwell WASHINGTON (Reuters) - ...</p>';
$pattern = "/(?<=href=(\"|'))[^\"']+(?=(\"|'))/";
$new_des = preg_replace($pattern,"?url=".$link,$description);
How can I do that in javascript?
pattern = /(href=["'])[^"']+(?=["'])/
new_des = description.replace(pattern, "$1?url=" + link)
JS doesn't support lookbehinds, therefore you'll have to capture the first group and insert it back when replacing using $1.

Matching string with preg_match [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have the following string formats: "$ 3.20" or "$ 10.34". I want to verify with preg_match if the string is exactly this type of a format.
Any suggestions are appreciated?
Try this pattern:
if (preg_match('/\$\s[\d]+\.[\d]{2}/', $text)){
//do something
}

How to parse HTML and preformat using php [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have text like this Too early to post? http://www.somewebsite.com/article/226973 I want to parse the hyperlinks in the text and make the text look like so Too early to post? http://www.entrepreneur.com/article/226973 I want to do this but I have no idea where to start from or what regexp to use.
$s = 'Too early to post? https://www.somewebsite.com/article/226973';
$parsed = preg_replace('#(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)#', '$1', $s);
echo $parsed;

Categories