I want to create a tool that reformats SQL scripts by adjusting keyword cases and adding formatting symbols. Is regex the ideal solution, or are there better alternatives?
hey guys, im wonderin if a proper sql parser might be more robust than regex for tricky syntax. any of you tried libaries like antlr? im curious to hear bout your experiance and what worked bettr for you.
hey, i tried a reusable sql formatting lib before and it worked better. regex soon falls apart if you have nested subqueries etc. might be wiser to look into a dedicated parser for your needs.
Based on my experience developing similar SQL formatting tools, regex can prove to be effective for basic case adjustments and symbol insertions; however, I encountered significant limitations when dealing with complex SQL structures such as nested queries or flexible dialect variations. A more robust approach that I found useful involved leveraging a proper SQL parser. This method not only mitigates potential regex pitfalls but also enhances reliability and maintainability. Furthermore, the parser option offers clearer error handling which is an advantage during debugging. Exploring parser libraries has been rewarding, as they offer a long-term solution that scales well with intricate SQL scripting requirements.
hey, im thinking a mix of regex for simple tweaks and a parser for deeper structure may work better. have u tried such combos? i reckon it can handle edge cases tho it might add complexity. what were your experieces wit hybrids?