View Single Post
Old 05-10-2023, 01:46 PM   #7
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,692
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
TagMechanic parses html in order to edit, delete, and modify tags. It knows which closing tag goes with which opening tag so that it can make correct edits to snarls of nested tags. It will not get confused in nested situations. Nor will it get "greedy" as regex is prone to do. TagMechanic is a subtle, HTML aware tool that can be used with precision to change, cleanup or delete html tags. Regex is blunt instrument that knows nothing about the markup it is trying to match/replace.

I like regex--use it all the time. But that doesn't change the fact that turning it loose on the kind of xhtml that needs to be properly parsed to be safely edited is like throwing a bag of hammers at a box of nails and a pile lumber and hoping a chair gets made.

I learned a long time ago to use regex where it makes sense (and there's tons of places it does). But don't try to use it to parse markup. It will eventually let you down.

I'm not saying that regex might not be the better choice for your situation. I'm just saying that a precision tool used to make smart, safe, changes to convoluted/nested html cannot be accurately described as a "hammer."
DiapDealer is online now   Reply With Quote