Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8949199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:10:39+00:00 2026-06-15T13:10:39+00:00

I want to get the js file by PHP CURL, then using regular express

  • 0

I want to get the js file by PHP CURL, then using regular express to get the value of var pluses, so the output should be /\+/g. Could someone advise what wrong with my code?

Thanks

Here is what I have tried, but no luck:

$url = 'http://cdn.jsdelivr.net/jquery.cookie/1.3/jquery.cookie.js';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

preg_match('/^var\spluses\s=\s/', $output, $match);
print_r($match);

Live code: http://phpfiddle.org/main/code/x4w-cn5

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:10:40+00:00Added an answer on June 15, 2026 at 1:10 pm

    To get your match, you need to select it. try

    preg_match('/var\spluses\s=\s(.*);/', $output, $match);
    

    The value assigned to pluses should be in $match[1].

    The ^ at the beginning of your regex is the start of line delimiter, which limited the selection to a line starting with the characters var, not considering the indentation.

    preg_match('/^\s*var\spluses\s=\s(.*);/', $output, $match);
    

    This regex would limit to a line with any (*) whitespaces before the var keyword.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read file headers using java, I want to get file
I want to get the type of file uploaded using the ASP.NET FileUpload control.
I want to download a remote file with curl and output it instantly to
I am using PHP curl to retrive an xml file from a remote url
With php file_get_contents() i want just only the post and image. But it's get
I want to get the file names of all files that have a specific
I want to get the file extension of uploaded file in Marklogic server. I
I want to get the file name without the file extension in Vim. I
I have a Html form. I want to get the file containing posted form's
i want query a file xml with linq, i want get all descendat of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.