How to find specific string by regex preg_match

Sufyan

I want to get the link by applying preg_match in php here is my code

$string = playlist: [{
        image: "http://77.81.98.55/i/01/00012/d6ntku2p3tnn.jpg",
        provider: "http://static.vidzi.tv/nplayer/vidzi.swf",
        sources: [{
            file: "http://vidzi.tv/6c90fqha0k9i-4b4a926f75863405c12bfaeb331b331c.m3u8?embed=",
            type: 'hls'
        },{
        file: "http://77.81.98.55/gzuqiu4h342qedz7nknr5h3sli74im5vv7f2ae7z2pxjxhqnqxk4625rsdpq/v.mp4"
        }]
        ,tracks: [{file: "http://vidzi.tv/6c90fqha0k9i-4b4a926f75863405c12bfaeb331b331c.vtt", kind: "thumbnails"}]
    }]

preg_match('/file: "(.*?)",/i', $result, $dl_link);

echo '<pre>';
print_r($dl_link);
echo '</pre>';

And the output is

Array
(
    [0] => file: "http://vidzi.tv/6c90fqha0k9i-4b4a926f75863405c12bfaeb331b331c.m3u8?embed=",
    [1] => http://vidzi.tv/6c90fqha0k9i-4b4a926f75863405c12bfaeb331b331c.m3u8?embed=
)

From above preg_match i get first

file: "http://vidzi.tv/6c90fqha0k9i-4b4a926f75863405c12bfaeb331b331c.m3u8?embed="

but i want to get this

file: "http://77.81.98.55/gzuqiu4h342qedz7nknr5h3sli74im5vv7f2ae7z2pxjxhqnqxk4625rsdpq/v.mp4"

help me thanks

anubhava

Since this appears to be broken JSON string you can use this regex:

preg_match_all('/file:\h*"([^"]*)"/i', $string, $m);

print_r($m[1][1]);
//=> http://77.81.98.55/gzuqiu4h342qedz7nknr5h3sli74im5vv7f2ae7z2pxjxhqnqxk4625rsdpq/v.mp4

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to find specific string by regex preg_match

From Dev

Why does preg_match doesn't find a string between tags when regex is OK?

From Dev

How to construct regex for preg_match in php

From Dev

How to alter my regex so that preg_match returns the desired string

From Dev

How to get specific string from the bunch of texts in reverse order using preg_match() in PHP

From Dev

How to find more than one variable in a string using preg_match?

From Dev

How to preg_match first occurrence in a string

From Dev

Regex: Preg_match - Specific search works in English but not in Hebrew

From Dev

Regex: Preg_match - Specific search works in English but not in Hebrew

From Dev

php, regex preg_match a specific word 0 or 1 time

From Dev

preg_match find regex with or without first capital letter

From Dev

Regex / preg_match to find 13 character unique ID

From Dev

Preg_match to find img src in specific img-tag

From Dev

Display contents of a string in html table using preg_match and regex

From Dev

preg_match to check if string has specific structure

From Dev

preg_match to allow specific special characters in string

From Dev

php preg_match find difficult JSON from string

From Dev

Regex and preg_match

From Dev

PHP and regex: how to preg_match on multiple line?

From Dev

Preg_match (REGEX) -- how to differentiate between accredited and credit?

From Dev

how do I write this regex expression to use with with preg_match?

From Dev

How to match string starting with specific charachter in regex

From Dev

How to preg_match specific javascript element to get values?

From Dev

How to find pattern matching and save to array with preg_match

From Dev

preg_match or preg_match_all to find all words in string with anything between them

From Dev

Regex match a specific string

From Dev

Regex Specific Match String

From Dev

How to set minimum string length for preg_match

From Dev

How to display text from a string differently depending on preg_match?

Related Related

  1. 1

    How to find specific string by regex preg_match

  2. 2

    Why does preg_match doesn't find a string between tags when regex is OK?

  3. 3

    How to construct regex for preg_match in php

  4. 4

    How to alter my regex so that preg_match returns the desired string

  5. 5

    How to get specific string from the bunch of texts in reverse order using preg_match() in PHP

  6. 6

    How to find more than one variable in a string using preg_match?

  7. 7

    How to preg_match first occurrence in a string

  8. 8

    Regex: Preg_match - Specific search works in English but not in Hebrew

  9. 9

    Regex: Preg_match - Specific search works in English but not in Hebrew

  10. 10

    php, regex preg_match a specific word 0 or 1 time

  11. 11

    preg_match find regex with or without first capital letter

  12. 12

    Regex / preg_match to find 13 character unique ID

  13. 13

    Preg_match to find img src in specific img-tag

  14. 14

    Display contents of a string in html table using preg_match and regex

  15. 15

    preg_match to check if string has specific structure

  16. 16

    preg_match to allow specific special characters in string

  17. 17

    php preg_match find difficult JSON from string

  18. 18

    Regex and preg_match

  19. 19

    PHP and regex: how to preg_match on multiple line?

  20. 20

    Preg_match (REGEX) -- how to differentiate between accredited and credit?

  21. 21

    how do I write this regex expression to use with with preg_match?

  22. 22

    How to match string starting with specific charachter in regex

  23. 23

    How to preg_match specific javascript element to get values?

  24. 24

    How to find pattern matching and save to array with preg_match

  25. 25

    preg_match or preg_match_all to find all words in string with anything between them

  26. 26

    Regex match a specific string

  27. 27

    Regex Specific Match String

  28. 28

    How to set minimum string length for preg_match

  29. 29

    How to display text from a string differently depending on preg_match?

HotTag

Archive