Jump to content

match string in html file


playwright

Recommended Posts

Is there a way to search in html file for a specific string and the same string plus some other content? For example:

abc.php?t=123 and also abc.php?t=123&page=2 and abc.php?t=123&page=3. Is there a regex that can do the job along with preg_match()?

Link to comment
Share on other sites

Depends how rigidly you can actually define the requirement. Given the examples you have it's hard to say as you don't specify an example input, but you would match the first part with the pattern.

 

abc\.php\?t=123

 

Depending on how the 'links' are listed in your page you could then use something like....

 

[^"]*
// or
\S*

 

... to match the rest of the query_string. Effectvely giving you a pattern such as...

 

#abc\.php\?t=123[^"]*#

Link to comment
Share on other sites

ok i will be more specific..the code is this one:

 

<a class="paginationLink" href="showthread.php?t=123&page=2"

title="Display results">2</a>

 

I want to be able to use a regex or something else so as to grab all href like this one (and also showthread.php?t=123&page=3 and showthread.php?t=123) and then use file_get_contents() to grab contents from all these files.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.