Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Well, use regex and you'd have two problems ;)
Though I use them quite a bit myself. -
Should've mentioned that it was a quote from Jamie Zawinski
Badicaly some coders use it incorreclty because it's not well understood. Also using it in could let edge cases to be missed. For instance parsing html ...
As I said, I use quite a bit, in code, vim, awk, sed ... -
@rusty-hacker Well if anybody wants to parse HTML with regex, then something is clearly going wrong with his/her thought process...
-
@qbasic16 Then something is clearly going wrong with my thought process. I think regex are great for any parsing. Haven't always liked regex though, used to find them cumberlicated [my own word for cumbersome/complicated]. But, the more I've learnt about them, the more I've become to like them. Or as Arnie would put it: "The mooawr I luearn, the mooawr *in*hyooman I becooawm".
-
@TerriToniAX I see your point and in most languages this makes absolutely sense. The problem with HTML is, that too many things can be in the code which are too complicated for regex. Like embedded PHP, JS code in script blocks containing HTML tags as string, iframe stuff, ...
If you master it with regex only I will personally handcraft you a medal 😂 -
@qbasic16 With one single regex only, no. With multiple subsequent regex, yes. The trick is to extract any embedded code, store those codes in an array and replace with some string like "{code}". Then, once you've parsed the remaining html, replace all those "{code}" with the elements in the array.
-
RegEx is great for parsing regular languages, which is why it's called "regular expression". However, people often use it to parse context-free languages, for which they're woefully inappropriate. That's where the saying comes from.
Programming languages, markup languages, and any language which allows nesting definitions, are never regular languages.
Related Rants
Working with a "senior frontend developer"
HIM: committed this code, and took him 2 weeks before his first commit on our project
var str = ''
if (string == 'String Here') {
str = 'stringhere'
} else if ( string == 'Another String Here') {
str = 'anotherstringhere'
} and so on ...
ME: WTF?
ME: can we do it like this?
ME: str = string.replace(/\s/g, '').toLowerCase()
Maybe he is senior by age :D
undefined
javascript
frontend