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

  • SEARCH
  • Home
  • 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 8405647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:53:48+00:00 2026-06-09T22:53:48+00:00

I have some code that extracts a bunch of data and stores the result

  • 0

I have some code that extracts a bunch of data and stores the result into a variable.
When I try to run a reg expression on it, it is unable to find a match. But if I dump the variable to screen by doing an echo statement, and then copy all the data from the screen into a variable and run the regex on the new variable then it is able to find 80+ matches.

Here is the code that I am currently using:

  require 'HPVC.php';

  $hp = new HPVC('10.14.3.23', '123', '');
  echo "<br>Attempting connection";

  $hp->connect();
  echo "<br>connection succeeded";
  $data = $hp->showPSAll();
  echo "<br>closing connection...";
  $hp->close();
  echo "<br>connection closed.";

  print_r($data);
  $pattern = '/(\w+)(\s*)(\w+\/\w+|\s+)(\s*)(\|)(\s*)(\w+)(\s*)(\w+)(\s*)(\w+|\s+)(\s*)(\w+)(\s*)(\w+)(\s*)(\w+)(\s*)(\d)/i';
  echo '<br>Number of matches: '.preg_match_all($pattern, $data, $matches, PREG_PATTERN_ORDER);

Here’s what the print_r gives in part :(it’s really really long!)

         connection closed. [24;1H [24;16H [24;1H [?25h [24;16H [24;16Hshow inter [24;16H [?25h [24;26H [24;26Hfaces brie [24;26H [?25h [24;36H [24;36Hf [24;36H [?25h [24;37H [24;0H E [24;1H [24;37H [24;1H [2K [24;1H [?25h [24;1H [1;24r [24;1H Status and Counters - Port Status | Intrusion MDI Flow Bcast Port Type | Alert Enabled Status Mode Mode Ctrl Limit ------ --------- + --------- ------- ------ ---------- ---- ---- ----- A1 100/1000T | No Yes Down 1000FDx Auto off 0 A2 100/1000T | No Yes Down 1000FDx Auto off 0 A3 100/1000T | No Yes Down 1000FDx Auto off 0 A4 100/1000T | No Yes Down 1000FDx Auto off 0 A5 100/1000T | No Yes Down 1000FDx Auto off 0 A6 100/1000T | No Yes Down 1000FDx Auto off 0 A7 100/1000T | No Yes Down 1000FDx Auto off 0 A8 100/1000T | No Yes Down 1000FDx Auto off 0 A9 100/1000T | No Yes Down 1000FDx Auto off 0 A10 100/1000T | No Yes Down 1000FDx Auto off 0 A11 100/1000T | No Yes Down 1000FDx Auto off 0 A12 100/1000T | No Yes Down 1000FDx Auto off 0 A13 100/1000T | No Yes Down 1000FDx Auto off 0 A14 100/1000T | No Yes Down 1000FDx Auto off 0 A15 100/1000T | No Yes Down 1000FDx Auto off 0 A16 100/1000T | No Yes Down 1000FDx Auto off 0 A17 100/1000T | No Yes Down 1000FDx Auto off 0 [24;1H [2K [24;1H [1;24r [24;1H A18 100/1000T | No Yes Down 1000FDx Auto off 0 A19 100/1000T | No Yes Down 1000FDx Auto off 0 A20 100/1000T | No Yes Down 1000FDx Auto off 0 A21 100/1000T | No Yes Down 1000FDx Auto off 0 A22 100/1000T | No Yes Down 1000FDx Auto off 0 A23 100/1000T | No Yes Down 1000FDx Auto off 0 A24 100/1000T | No Yes Down 1000FDx Auto off 0 B1 100/1000T | No Yes Down 1000FDx Auto off 0 B2 100/1000T | No Yes Down 1000FDx Auto off 0 B3 100/1000T | No Yes Down 1000FDx Auto off 0 B4 100/1000T | No Yes Down 1000FDx Auto off 0 B5 100/1000T | No Yes Down 1000FDx Auto off 0 B6 100/1000T | No Yes 

Could someone please assist with this issue?

  • 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-09T22:53:49+00:00Added an answer on June 9, 2026 at 10:53 pm

    Check your raw data. What you may be copying is slightly different than what is in $data. An example of this might be non-white space characters displaying as white space and then being copied as white space. You might have to dump $data to a file with a binary write and then look at the characters with a hex editor.

    I have run into similar problems myself in the past.

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

Sidebar

Related Questions

I have some code that looks like this: foreach(var obj in collection) { try
I have an application that extracts data from some xml that is stored in
I ran into a bug in some code that extracts metadata from some text
I have some LINQ code that extracts bookmarks from PDFs that match a certain
So in PHP I have some code that extracts the day, month and year
I have some code that will change the background color of a specific label
I have some code that is supposed to return an NSString. Instead it is
I have some code that generates Visio masters for me, and some masters have
I have some code that causes the box2d physics simulation to stutter forever after
I have some code that runs a model in a loop. Each iteration 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.