Jump to content

Complex Regex


Brandon_R

Recommended Posts

I created a regex to match psp codes from full to basic

 

#!!999999999 Monies

0x00000000 0x00000000

;this is a comment

0x00000000 0x00000000 ; Mod this

;mod this

 

#Hello

0x00000000 0x00000000

 

Here it is

 

 

(#!*.+[\r\n]*(?:(?:;.+[\r\n]*)*(?:0x[a-f0-9]{8}\s0x[a-f0-9]{1,8}(?:\s*;.+)*[\r\n]*)*)+)

 

 

Can someone show me where i went wrong? Im pretty sure it's the newline as it checks for \r\n but im pertty sure on html pages its <br /> but still not positive. A Code can have one title and infinitly* many code lines followed by comment lines

Link to comment
Share on other sites

Given that input, what output are you trying to get?

 

Spoiler: if you want the hex values sans any comments, you can't do it with one regex. It'll take at least two: one to grab the entire block of text, and one to remove comments and extra whitespace.

Link to comment
Share on other sites

I actually want to match the entire psp code from an html page. Say we have a page with html such as title, head, meta, content etc. I want it to pull those psp codes from the page and hopefully into an array, one code per array element. It matches the code some times and other times it just doesn't get a match.

Link to comment
Share on other sites

Okay, well that didn't help at all. First you're changing the scope of the question entirely (by dealing with HTML documents) and secondly, no new information regarding what you've been trying, how they've been failing, etc..  How about showing us where you're at at the moment and how that does not do what you want it to do?

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.