What regexp do I need to find a string in PHP? The Next CEO of Stack OverflowHow can I prevent SQL injection in PHP?PHP: Delete an element from an arrayHow do you access the matched groups in a JavaScript regular expression?How do I make the first letter of a string uppercase in JavaScript?How to replace all occurrences of a string in JavaScriptReference — What does this symbol mean in PHP?How do I check if a string contains a specific word?How does PHP 'foreach' actually work?Reference - What does this error mean in PHP?Why shouldn't I use mysql_* functions in PHP?
Is it possible to search for a directory/file combination?
Is it my responsibility to learn a new technology in my own time my employer wants to implement?
Is it ever safe to open a suspicious html file (e.g. email attachment)?
Elegant way to replace substring in a regex with optional groups in Python?
Different harmonic changes implied by a simple descending scale
Is micro rebar a better way to reinforce concrete than rebar?
Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?
Contours of a clandestine nature
Workaholic Formal/Informal
How do scammers retract money, while you can’t?
What can we do to stop prior company from asking us questions?
"and that skill is always a class skill for you" - does "always" have any meaning in Pathfinder?
How do I go from 300 unfinished/half written blog posts, to published posts?
Bold, vivid family
What connection does MS Office have to Netscape Navigator?
Why do we use the plural of movies in this phrase "We went to the movies last night."?
What exact does MIB represent in SNMP? How is it different from OID?
Make solar eclipses exceedingly rare, but still have new moons
Do I need to enable Dev Hub in my PROD Org?
Should I tutor a student who I know has cheated on their homework?
Can I equip Skullclamp on a creature I am sacrificing?
Preparing Indesign booklet with .psd graphics for print
If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?
I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin
What regexp do I need to find a string in PHP?
The Next CEO of Stack OverflowHow can I prevent SQL injection in PHP?PHP: Delete an element from an arrayHow do you access the matched groups in a JavaScript regular expression?How do I make the first letter of a string uppercase in JavaScript?How to replace all occurrences of a string in JavaScriptReference — What does this symbol mean in PHP?How do I check if a string contains a specific word?How does PHP 'foreach' actually work?Reference - What does this error mean in PHP?Why shouldn't I use mysql_* functions in PHP?
I am trying to find the string:
sd_src:"https://video.fhyd6-1.fna.fbcdn.net/v/t42.9040-2/10000000_2379299605422668_4104252399957311488_n.mp4?_nc_cat=1&efg=eyJybHIiOjY0OCwicmxhIjoyODQ5LCJ2ZW5jb2RlX3RhZyI6InN2ZV9zZCJ9&rl=648&vabr=360&_nc_ht=video.fhyd6-1.fna&oh=2f555df6a07d18aa1f472d972dab0114&oe=5C80FCA5
in the source code of the link https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/ and to print that in PHP.
Look at the code you will understand:
<?php
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
preg_match('REGEXP', $sourceurl, $link);
echo $link;
?>
What is the regular expression to find this string in the source code of the $sourceurl?
php regex preg-match file-get-contents
add a comment |
I am trying to find the string:
sd_src:"https://video.fhyd6-1.fna.fbcdn.net/v/t42.9040-2/10000000_2379299605422668_4104252399957311488_n.mp4?_nc_cat=1&efg=eyJybHIiOjY0OCwicmxhIjoyODQ5LCJ2ZW5jb2RlX3RhZyI6InN2ZV9zZCJ9&rl=648&vabr=360&_nc_ht=video.fhyd6-1.fna&oh=2f555df6a07d18aa1f472d972dab0114&oe=5C80FCA5
in the source code of the link https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/ and to print that in PHP.
Look at the code you will understand:
<?php
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
preg_match('REGEXP', $sourceurl, $link);
echo $link;
?>
What is the regular expression to find this string in the source code of the $sourceurl?
php regex preg-match file-get-contents
Readers are generally very happy to help. However they will generally expect a prior attempt to be included in questions. If you have not done that yet, please do so, and edit it into the post.
– halfer
Mar 8 at 18:15
add a comment |
I am trying to find the string:
sd_src:"https://video.fhyd6-1.fna.fbcdn.net/v/t42.9040-2/10000000_2379299605422668_4104252399957311488_n.mp4?_nc_cat=1&efg=eyJybHIiOjY0OCwicmxhIjoyODQ5LCJ2ZW5jb2RlX3RhZyI6InN2ZV9zZCJ9&rl=648&vabr=360&_nc_ht=video.fhyd6-1.fna&oh=2f555df6a07d18aa1f472d972dab0114&oe=5C80FCA5
in the source code of the link https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/ and to print that in PHP.
Look at the code you will understand:
<?php
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
preg_match('REGEXP', $sourceurl, $link);
echo $link;
?>
What is the regular expression to find this string in the source code of the $sourceurl?
php regex preg-match file-get-contents
I am trying to find the string:
sd_src:"https://video.fhyd6-1.fna.fbcdn.net/v/t42.9040-2/10000000_2379299605422668_4104252399957311488_n.mp4?_nc_cat=1&efg=eyJybHIiOjY0OCwicmxhIjoyODQ5LCJ2ZW5jb2RlX3RhZyI6InN2ZV9zZCJ9&rl=648&vabr=360&_nc_ht=video.fhyd6-1.fna&oh=2f555df6a07d18aa1f472d972dab0114&oe=5C80FCA5
in the source code of the link https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/ and to print that in PHP.
Look at the code you will understand:
<?php
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
preg_match('REGEXP', $sourceurl, $link);
echo $link;
?>
What is the regular expression to find this string in the source code of the $sourceurl?
php regex preg-match file-get-contents
php regex preg-match file-get-contents
edited Mar 8 at 18:13
halfer
14.7k759116
14.7k759116
asked Mar 7 at 15:17
Chinna NChinna N
1
1
Readers are generally very happy to help. However they will generally expect a prior attempt to be included in questions. If you have not done that yet, please do so, and edit it into the post.
– halfer
Mar 8 at 18:15
add a comment |
Readers are generally very happy to help. However they will generally expect a prior attempt to be included in questions. If you have not done that yet, please do so, and edit it into the post.
– halfer
Mar 8 at 18:15
Readers are generally very happy to help. However they will generally expect a prior attempt to be included in questions. If you have not done that yet, please do so, and edit it into the post.
– halfer
Mar 8 at 18:15
Readers are generally very happy to help. However they will generally expect a prior attempt to be included in questions. If you have not done that yet, please do so, and edit it into the post.
– halfer
Mar 8 at 18:15
add a comment |
3 Answers
3
active
oldest
votes
You can use:
preg_match('~'.preg_quote($string, '~').'~i', $sourceurl, $link);
add a comment |
Your link don't need to be find by a Regex in your example.
You can do :
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
if ( stripos($sourceurl, $link))
// do something
$linkis what OP is trying to find in the HTML.
– user7290573
Mar 7 at 15:35
add a comment |
The most reliable way would be to use a HTML parser, but this should work:
<?php
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
preg_match('/sd_src:"(.*?)"/s', $sourceurl, $linkArray);
$link = $linkArray[1];
echo $link;
Hello ! thanks for your answer but it is throwing some error i just mentioned in the screenshot url(prntscr.com/munqx0) and i tried removing '[1]' but it is not working also.
– Chinna N
Mar 7 at 15:49
@ChinnaN what doesvar_dump($linkArray)show?
– user7290573
Mar 7 at 16:07
Hello there I have a query to ask you about finding REG EXP in PHP. Look at this quesion stackoverflow.com/questions/55059224/… and help me to find REG EX. Thank!
– Chinna N
Mar 8 at 8:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047167%2fwhat-regexp-do-i-need-to-find-a-string-in-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use:
preg_match('~'.preg_quote($string, '~').'~i', $sourceurl, $link);
add a comment |
You can use:
preg_match('~'.preg_quote($string, '~').'~i', $sourceurl, $link);
add a comment |
You can use:
preg_match('~'.preg_quote($string, '~').'~i', $sourceurl, $link);
You can use:
preg_match('~'.preg_quote($string, '~').'~i', $sourceurl, $link);
answered Mar 7 at 15:24
NathaNatha
18318
18318
add a comment |
add a comment |
Your link don't need to be find by a Regex in your example.
You can do :
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
if ( stripos($sourceurl, $link))
// do something
$linkis what OP is trying to find in the HTML.
– user7290573
Mar 7 at 15:35
add a comment |
Your link don't need to be find by a Regex in your example.
You can do :
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
if ( stripos($sourceurl, $link))
// do something
$linkis what OP is trying to find in the HTML.
– user7290573
Mar 7 at 15:35
add a comment |
Your link don't need to be find by a Regex in your example.
You can do :
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
if ( stripos($sourceurl, $link))
// do something
Your link don't need to be find by a Regex in your example.
You can do :
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
if ( stripos($sourceurl, $link))
// do something
answered Mar 7 at 15:27
VinzVinz
18127
18127
$linkis what OP is trying to find in the HTML.
– user7290573
Mar 7 at 15:35
add a comment |
$linkis what OP is trying to find in the HTML.
– user7290573
Mar 7 at 15:35
$link is what OP is trying to find in the HTML.– user7290573
Mar 7 at 15:35
$link is what OP is trying to find in the HTML.– user7290573
Mar 7 at 15:35
add a comment |
The most reliable way would be to use a HTML parser, but this should work:
<?php
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
preg_match('/sd_src:"(.*?)"/s', $sourceurl, $linkArray);
$link = $linkArray[1];
echo $link;
Hello ! thanks for your answer but it is throwing some error i just mentioned in the screenshot url(prntscr.com/munqx0) and i tried removing '[1]' but it is not working also.
– Chinna N
Mar 7 at 15:49
@ChinnaN what doesvar_dump($linkArray)show?
– user7290573
Mar 7 at 16:07
Hello there I have a query to ask you about finding REG EXP in PHP. Look at this quesion stackoverflow.com/questions/55059224/… and help me to find REG EX. Thank!
– Chinna N
Mar 8 at 8:27
add a comment |
The most reliable way would be to use a HTML parser, but this should work:
<?php
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
preg_match('/sd_src:"(.*?)"/s', $sourceurl, $linkArray);
$link = $linkArray[1];
echo $link;
Hello ! thanks for your answer but it is throwing some error i just mentioned in the screenshot url(prntscr.com/munqx0) and i tried removing '[1]' but it is not working also.
– Chinna N
Mar 7 at 15:49
@ChinnaN what doesvar_dump($linkArray)show?
– user7290573
Mar 7 at 16:07
Hello there I have a query to ask you about finding REG EXP in PHP. Look at this quesion stackoverflow.com/questions/55059224/… and help me to find REG EX. Thank!
– Chinna N
Mar 8 at 8:27
add a comment |
The most reliable way would be to use a HTML parser, but this should work:
<?php
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
preg_match('/sd_src:"(.*?)"/s', $sourceurl, $linkArray);
$link = $linkArray[1];
echo $link;
The most reliable way would be to use a HTML parser, but this should work:
<?php
$sourceurl = file_get_contents('https://www.facebook.com/PeinadosFacilesRapido/videos/399225660865821/');
preg_match('/sd_src:"(.*?)"/s', $sourceurl, $linkArray);
$link = $linkArray[1];
echo $link;
answered Mar 7 at 15:32
user7290573user7290573
45726
45726
Hello ! thanks for your answer but it is throwing some error i just mentioned in the screenshot url(prntscr.com/munqx0) and i tried removing '[1]' but it is not working also.
– Chinna N
Mar 7 at 15:49
@ChinnaN what doesvar_dump($linkArray)show?
– user7290573
Mar 7 at 16:07
Hello there I have a query to ask you about finding REG EXP in PHP. Look at this quesion stackoverflow.com/questions/55059224/… and help me to find REG EX. Thank!
– Chinna N
Mar 8 at 8:27
add a comment |
Hello ! thanks for your answer but it is throwing some error i just mentioned in the screenshot url(prntscr.com/munqx0) and i tried removing '[1]' but it is not working also.
– Chinna N
Mar 7 at 15:49
@ChinnaN what doesvar_dump($linkArray)show?
– user7290573
Mar 7 at 16:07
Hello there I have a query to ask you about finding REG EXP in PHP. Look at this quesion stackoverflow.com/questions/55059224/… and help me to find REG EX. Thank!
– Chinna N
Mar 8 at 8:27
Hello ! thanks for your answer but it is throwing some error i just mentioned in the screenshot url(prntscr.com/munqx0) and i tried removing '[1]' but it is not working also.
– Chinna N
Mar 7 at 15:49
Hello ! thanks for your answer but it is throwing some error i just mentioned in the screenshot url(prntscr.com/munqx0) and i tried removing '[1]' but it is not working also.
– Chinna N
Mar 7 at 15:49
@ChinnaN what does
var_dump($linkArray) show?– user7290573
Mar 7 at 16:07
@ChinnaN what does
var_dump($linkArray) show?– user7290573
Mar 7 at 16:07
Hello there I have a query to ask you about finding REG EXP in PHP. Look at this quesion stackoverflow.com/questions/55059224/… and help me to find REG EX. Thank!
– Chinna N
Mar 8 at 8:27
Hello there I have a query to ask you about finding REG EXP in PHP. Look at this quesion stackoverflow.com/questions/55059224/… and help me to find REG EX. Thank!
– Chinna N
Mar 8 at 8:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047167%2fwhat-regexp-do-i-need-to-find-a-string-in-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Readers are generally very happy to help. However they will generally expect a prior attempt to be included in questions. If you have not done that yet, please do so, and edit it into the post.
– halfer
Mar 8 at 18:15