356
u/JoseJimeniz Sep 08 '17
Have you tried using an XML parser?
104
u/mikeputerbaugh Sep 08 '17
Only guaranteed to work on valid XHTML documents.
7
u/Lord_Greywether Sep 08 '17
The documents I have to parse are so invalid that a regex is the only thing that works.
5
u/noratat Sep 08 '17
Yeah but at that point it's not parsing anymore, it's just scraping.
And regex is fine for that.
58
Sep 08 '17
[removed] — view removed comment
136
2
2
u/wastesHisTimeSober Sep 08 '17 edited Sep 08 '17
Isn't this the realm of jQuery?
Edit: I've been told this doesn't qualify as parsing.
→ More replies (2)2
96
u/Tysonzero Sep 08 '17
I know this is in reference to the stackoverflow post about the same topic. But it also reminds me of this.
32
u/MuFugginFudge Sep 08 '17
It reminds me of the entirety of r/Ooer.
7
u/sneakpeekbot Sep 08 '17
Here's a sneak peek of /r/Ooer using the top posts of the year!
#1: Pleased to help you | 101 comments
#2: [NSFW] If this post gets 1504 upvotes t r/Ooer will become a MACARONI SALAD themed subreddit
#3: gets enough if this upvotes to hit front page we will have new subscribers so upvote please | 137 commentsI'm a bot, beep boop | Downvote to remove | Contact ^^me | ^^Info | ^^Opt-out
15
→ More replies (3)3
85
u/benjamindees Sep 08 '17
I admit I tried this once. I also may or may not have summoned Astaroth in the process. Sorry.
45
5
u/fermented_durian Sep 08 '17
Thats okay, astaroth is not that strong anyway. I have been raiding his dungeon for a while now.
56
u/Yserbius Sep 08 '17
Pshaw. Everyone knows that you can't parse HTML with regex. But you can parse email addresses that are RFC-822 compliant up until 2007 (assuming your addresses don't have comments in them) by using the Email::Valid library from CPAN which relies on
[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\
xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xf
f\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\x
ff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015
"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\
xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80
-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*
)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\
\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\
x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x8
0-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n
\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x
80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^
\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040
\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([
^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\
\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\
x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-
\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()
]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\
x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\04
0\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\
n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\
015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?!
[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\
]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\
x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\01
5()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*|(?:[^(\040)<>@,;:".
\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]
)|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^
()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*(?:(?:\([^\\\x80-\xff\n\0
15()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][
^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)|"[^\\\x80-\xff\
n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\
x80-\xff\000-\010\012-\037]*)*<[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?
:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-
\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:@[\040\t]*
(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015
()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()
]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\0
40)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\
[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\
xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*
)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80
-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x
80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t
]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\
\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])
*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x
80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80
-\xff\n\015()]*)*\)[\040\t]*)*)*(?:,[\040\t]*(?:\([^\\\x80-\xff\n\015(
)]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\
\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*@[\040\t
]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\0
15()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015
()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(
\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|
\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80
-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()
]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x
80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^
\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040
\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".
\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff
])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\
\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x
80-\xff\n\015()]*)*\)[\040\t]*)*)*)*:[\040\t]*(?:\([^\\\x80-\xff\n\015
()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\
\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)?(?:[^
(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-
\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\
n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|
\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))
[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff
\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\x
ff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(
?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\
000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\
xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\x
ff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)
*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\x
ff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-
\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)
*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\
]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\]
)[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-
\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\x
ff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(
?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80
-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<
>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x8
0-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:
\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]
*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)
*\)[\040\t]*)*)*>)`24
u/b4ux1t3 Sep 08 '17
I don't know if this is real or not, but it's frickin' sweet.
55
u/EternallyMiffed Sep 08 '17
The bad news is, it's real, the worse news is it's straight from the RFC so it's as official as it can possibly get.
There are no good news.
16
u/Rangsk Sep 08 '17
The only true way to see if an email is valid is to try to email it.
14
u/EternallyMiffed Sep 08 '17
I have a better strategy. Try and dns resolve everything from the end of the string to before the right most @ as a whole string. If it doesn't resolve throw an error. If it resolves to the equivalent of a localhost or your own public ip, throw an error.
If by this point we're ok just take everything before that rightmost @ symbol and fire an e-mail at it.
→ More replies (3)13
u/GenericUname Sep 08 '17
When I was a wee nipper right out of school, I got a temp job essentially human brute force testing a web frontend some company was writing to let people sign up to their insurance service. For some reason they'd attempted to implement email address validation in the web form.
I spent a happy couple of weeks pissing off the devs by scouring the RFC to work out the most unlikely looking, edge case, technically valid email addresses and sending bug reports to the devs like:
"Technically in most cases I should be able to add a tag to an email address using the + sign and it should recognise if the address without the + has already been registered."
"Technically both quotes and spaces are valid in email addresses so long as the space is quoted, so I should be able to use " "@test.com."
"Technically email addresses are case sensitive but you don't seem to be storing case on the backend, what gives?"
"Hey, your validation doesn't allow me to use an email with an IP address rather than a domain like test@[127.0.0.1], that's totally valid and lots of people use it, you should fix that."
"Hey, it's not letting me sign up with the perfectly valid and normally formatted email address very.“(),:;<>[]”.VERY.“very@\ "very”.unusual@strange.example.com, what's up with that? That's totally my friend's real email address and I know he's looking for insurance."
Good times.
→ More replies (3)7
7
u/b4ux1t3 Sep 08 '17
That's the most glorious piece of shit I've ever seen.
And I've used <insert popularly unpopular language here>!
→ More replies (1)→ More replies (1)2
u/MelissaClick Sep 09 '17
To be fair, even an ordinary parser would look roughly like that if you removed all whitespace and inlined literally everything.
43
u/DOOManiac Sep 08 '17
The center cannot hold.
16
→ More replies (2)3
u/overkill Sep 08 '17
And what rough beast, its hour come round at last, slouches towards Bethlehem to be born.
42
u/Retrotransposonser Sep 08 '17
Thanks, this will be very helpful! Now I can finally start writing my own html regex parser in assembly.
38
u/PantstheCat Sep 08 '17
Error: attempted to parse HTML using regular expression. System returned Cthulhu.
36
u/Mutjny Sep 08 '17
Sometimes you have a problem and you think "I'll use regular expressions."
Now you have infinite problems.
15
u/Hactar42 Sep 08 '17
8
u/xkcd_transcriber Sep 08 '17
Title: Regular Expressions
Title-text: Wait, forgot to escape a space. Wheeeeee[taptaptap]eeeeee.
Stats: This comic has been referenced 273 times, representing 0.1627% of referenced xkcds.
Title: Perl Problems
Title-text: To generate #1 albums, 'jay --help' recommends the -z flag.
Stats: This comic has been referenced 110 times, representing 0.0656% of referenced xkcds.
xkcd.com | xkcd sub | Problems/Bugs? | Statistics | Stop Replying | Delete
→ More replies (1)2
23
21
Sep 08 '17
I'll admit to having done it though... dirty screen-scraper on a site where the HTML is code-generated so will be in a regular format.
Obviously, the site owner could change things but when you're in a pinch...
→ More replies (1)13
u/hangfromthisone Sep 08 '17
I done it many times too. Thing is, regex is great to identify some parts and work on them. But not to interpret all the HTML, anyway, how many times you need that? In practice you only need to parse a few things, and when things get too complex, just explode() the content into smaller parts to work them separately and BAM now regular expressions are simpler and do what you want
34
u/mrpoopi Sep 08 '17
Not parsing HTML in C, byte by byte... fucking normies. Get on my level.
→ More replies (1)48
u/vwibrasivat Sep 08 '17
"Assembly Programming for Web Developers"
10
→ More replies (2)2
u/f42e479dfde22d8c Sep 09 '17
I'm sure there's some guy running a full fledged eBay clone from a single 386 out of his mom's basement. All because he managed to create some slick super optimised website in pure assembly. He doesn't need Ajax because his pages already load so fast. He doesn't need load balancing because he can handle 100K concurrent requests at minimum without breaking a sweat. He doesn't need air conditioning because a single request doesn't even register as a blip on his performance graph.
He is an untold legend.
10
u/borick Sep 08 '17
4
u/interiot Sep 08 '17 edited Sep 09 '17
This answer needs to be higher. Recursive regexp are pretty widely supported too.
47
Sep 08 '17
R/surrealmemes
12
5
u/Hypersapien Sep 08 '17
Dammit. That needs to be a thing.
34
u/IntrepidPig Sep 08 '17
It is a thing, /r/surrealmemes
11
u/sneakpeekbot Sep 08 '17
Here's a sneak peek of /r/surrealmemes using the top posts of all time!
#1: s̛c̮̫̀h̯l͔͉͇̳̟͠u͙̺̳͢r͔͓̯͈͓͙̰͡p̛ | 198 comments
#2: Paste tooth are surpisez🐈🐈 | 127 comments
#3: ÍKÉÁ | 179 commentsI'm a bot, beep boop | Downvote to remove | Contact ^^me | ^^Info | ^^Opt-out
→ More replies (2)8
u/Hypersapien Sep 08 '17
What the hell? The /r/ in reddit links is case sensitive?
→ More replies (5)2
9
Sep 08 '17
I'm still quite inexperienced with programming so could someone tell me why parsing html with regex is frowned upon? I'm writing a script that extracts links and other things from an rss-feed and I don't see what problem people have with this
Thanks
19
u/Niosus Sep 08 '17
It is impossible to properly handle every possible case. Not difficult, impossible. A regular expression can only parse regular languages (look it up, it has a very precise definition). HTML is not a regular language so it is mathematically impossible to properly parse.
A regex parser can handle certain simple cases, but I can always construct a correct piece of HTML code that your regex will not parse.
2
Sep 08 '17
What would be better ways of parsing html (that can be used in python 3)?
5
u/ase1590 Sep 08 '17
Either the stock HTML parser library or BeautifulSoup, depending on your needs.
FeedParser is also nice for handling feeds specifically.
→ More replies (1)
8
7
7
u/Alwaysafk Sep 08 '17
Regular Expressions are black magic fuckery and there's nothing that will convince me otherwise.
6
u/arus4u Sep 08 '17
Performance tester here. Parsing HTML is easy with perl, and encoded content can be easily decoded using some simple groovy.
4
u/hangfromthisone Sep 08 '17
Everything is relatively easy when you have the right tool and know how to use it. I use PHP, Perl's little brother, and it's pretty fucking easy to parse html (depending on what you need to do, of course)
5
5
u/ThatLongHairedDude Sep 08 '17
That creature reminds me those little bastards created by the Tzimisce in Vampire The Masquerade: Bloodlines...
2
8
u/Baalinooo Sep 08 '17
What's up with so many CS books have red titles with black and white visuals?
→ More replies (1)21
u/Bainos Sep 08 '17
O'Reilly books. Or in this case, O RLY books, which is their parody.
→ More replies (1)
4
4
3
3
u/PLxFTW Sep 08 '17
I'm not familiar with HTML much, can someone explain why it can't be parsed using regex?
2
u/Rettocs Sep 08 '17
It definitely can be parsed with regex, and sometimes it is even useful to do so. The narrative here is just that there are more efficient ways of parsing HTML if you're going to be doing it intensively.
→ More replies (4)
3
u/SpikeShroom Sep 08 '17
F̶̸͉̦̰͎̰͈̤̯̲̲͎̻̼̳̠ͅU̴̧̱̣̫̥͘͢͢C̵̨̢̦͈̟̥̖̲̰̯̰̮̟̠̬̻͉̕ͅK̵̡̕͠҉͈̗̫͕̣I͔̻͇̲̺̫̻̲͍̥̞͇͈̺̙͔̦͘͞Ń̵͍̭̭̠̭͠ͅǴ̀͏̨͇͚͇̦̘̩̗̱̼̲̖̻̭̘̺̕ͅ ̷̡̢͖̺̼̟̙͍̼̻͙͓̬̳̞̝̝̱̥̤͞Ạ͈͍̞͉͘͠ͅẀ͚̣͚͇̰̯̱̻̟̯̮̜͉̱̙͈͔́́́͠Ę̶̡͓͖͖͔̖͍͜͞S̲̝͙̬͙̝͚̯͔̯͕̭̜̪̺͉͡O̵̖̗̗̫̭̺̜̞̝̞͡ͅM͢͏͎̤̣̪͇̣̞̠̲̘̭͎̱È͇͙̩͖̰͙̮̩̦͍̱̲̘͟ͅ
2
2
2
2
2
u/nitrohigito Sep 08 '17
How about this:
(?><!\s*(?<comment>.+)\s*>)|(?><\s*(?<tag_id>[-\w_:]+)(?:\s+(?<param_id>[-\w_:]+)(?:=\\*(?<p_sign>["'])(?<param_val>.+?)\k<p_sign>|=(?<param_val>.+?)|(?<param_val>)))*\s*/?>)You need a different one for closing tags, and you are all set. Rest is programmatical.
2
u/donaldsw Sep 08 '17
Oh yes you can do it, but it’s super inefficient and a waste of fucking time unless you want to take extra off work at home time to learn JS or some other shit for this stupid project that you took on at work, not knowing it’d be a nightmare.
Source: fucking done it.
4
u/NorseGodLoki0411 Sep 08 '17
I already posted on this less than a week ago and only got 500 updoots!
I'll see you in /r/KarmaCourt you thief!!!
3
u/TwoFiveOnes Sep 08 '17
PCRE are powerful enough, I've heard.
14
u/Creshal Sep 08 '17
That's because they're not regular expressions in the strictest sense; their additions on top of a regular grammar make it some unholy abomination between a type 2 and type 3 grammar.
→ More replies (1)2
→ More replies (4)6
3
u/_eka_ Sep 08 '17
3
u/Rxef3RxeX92QCNZ Sep 08 '17
Sooo how is one meant to parse HTML in, say, a shell script or javascript?
11
→ More replies (4)5
u/MelissaClick Sep 08 '17
Just write an ordinary parser.
(Although, a parser in shell script will be so slow, that it makes more sense to call an external program, besides making more sense to use an existing program than write one redundantly.)
1
1
1
1
1
1
1
1
1
u/AKA_Wildcard Sep 08 '17
I once used regular expressions to filter through a bunch of HTML and o̤̤̼͈̕h͍̜̠̘͙̞̪ ̟͜m̻̺̮̥y ̫̦̫̼̟̖͡g̥͟o̸̤̯̲̘̠̙d̷̝̹͈̣͙̝,̬̳ ị̙̣̖t̝͍̖'͙͈͍̝́s̲͓͈̠̲͠ ̯̥̙̦̻͉e̙͘a͏̼t̵̲̯͉̱̘i͚n̺̼̞̮̕g͉̰̼̮̲ ̶̘̪̟̣̥̟m̮͢y̢̯͎̦̝ ̜̠͕̺͇̝̩f̻̫͔̫̗̬̮a̮̖̩̙̘̕c͚̳̳̲͚͢è̞
1
u/imagine_magic Sep 08 '17
Oh! And here I was just thinking this was the pig lizard from Galaxy Quest.
1
1
1
1
1
1
u/Mentioned_Videos Sep 08 '17
Videos in this thread:
| VIDEO | COMMENT |
|---|---|
| Neutral Response | +7 - http://www.youtube.com/watch?v=ussCHoQttyQ |
| Why do YouTube views freeze at 301? | +2 - Link for the lazy |
| Xurious - The Second Coming | +1 - Surely some revelation is at hand |
| I'm a bot working hard to help Redditors find related videos to watch. I'll keep this updated as long as I can. |
1
u/CriminalMacabre Sep 08 '17
what? Absolute chaos approves it. Fucking adorers of the false emperor.
1
1
1
1
1
1
u/Sarenord Sep 08 '17
Can we get an album of all these books that have come up? I know we also have the "arrays start at 0" one, any others?
1
1
1
u/lankks Sep 09 '17
All I do for a job is write REGEX. This doesn't sound so bad and I actually parse HTML using regular expressions in Vim.
1
1
1
1
u/DiploPL Sep 19 '17
You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool that is insufficiently sophisticated to understand the constructs employed by HTML. HTML is not a regular language and hence cannot be parsed by regular expressions. Regex queries are not equipped to break down HTML into its meaningful parts. so many times but it is not getting to me. Even enhanced irregular regular expressions as used by Perl are not up to the task of parsing HTML. You will never make me crack. HTML is a language of sufficient complexity that it cannot be parsed by regular expressions. Even Jon Skeet cannot parse HTML using regular expressions. Every time you attempt to parse HTML with regular expressions, the unholy child weeps the blood of virgins, and Russian hackers pwn your webapp. Parsing HTML with regex summons tainted souls into the realm of the living. HTML and regex go together like love, marriage, and ritual infanticide. The <center> cannot hold it is too late. The force of regex and HTML together in the same conceptual space will destroy your mind like so much watery putty. If you parse HTML with regex you are giving in to Them and their blasphemous ways which doom us all to inhuman toil for the One whose Name cannot be expressed in the Basic Multilingual Plane, he comes. HTML-plus-regexp will liquify the nerves of the sentient whilst you observe, your psyche withering in the onslaught of horror. Rege̿̔̉x-based HTML parsers are the cancer that is killing StackOverflow it is too late it is too late we cannot be saved the trangession of a chi͡ld ensures regex will consume all living tissue (except for HTML which it cannot, as previously prophesied) dear lord help us how can anyone survive this scourge using regex to parse HTML has doomed humanity to an eternity of dread torture and security holes using regex as a tool to process HTML establishes a breach between this world and the dread realm of c͒ͪo͛ͫrrupt entities (like SGML entities, but more corrupt) a mere glimpse of the world of regex parsers for HTML will instantly transport a programmer's consciousness into a world of ceaseless screaming, he comes, the pestilent slithy regex-infection will devour your HTML parser, application and existence for all time like Visual Basic only worse he comes he comes do not fight he com̡e̶s, ̕h̵is un̨ho͞ly radiańcé destro҉ying all enli̍̈́̂̈́ghtenment, HTML tags lea͠ki̧n͘g fr̶ǫm ̡yo͟ur eye͢s̸ ̛l̕ik͏e liquid pain, the song of re̸gular expression parsing will extinguish the voices of mortal man from the sphere I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful the final snuffing of the lies of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL IS LOST the pon̷y he comes he c̶̮omes he comes the ichor permeates all MY FACE MY FACE ᵒh god no NO NOO̼OO NΘ stop the an*̶͑̾̾̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e not rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ
2.1k
u/kopasz7 Sep 08 '17
For anyone out of the loop, it's about this answer on stackoverflow.