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
https://forums.phpfreaks.com/topic/233544-complex-regex/
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
https://forums.phpfreaks.com/topic/233544-complex-regex/#findComment-1200896
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
https://forums.phpfreaks.com/topic/233544-complex-regex/#findComment-1201424
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
https://forums.phpfreaks.com/topic/233544-complex-regex/#findComment-1201495
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.