feat: allow text matching with a regex
@lexanth , thank you a lot for your reply to https://github.com/lexanth/testing-library-table-queries/issues/31#issuecomment-1899194615
This PR aims to address the following point mentioned by https://github.com/lexanth/testing-library-table-queries/issues/31#issuecomment-1899194615:
Allow custom text normalisation/matching
I did so by allowing the caller of the methods to specify a regex to match against the HTML text content.
As much as I'd like to address the other points as well, this would be my first contribution to the package, so I've aimed to make this PR as simple as possible.
By the way, about the normalisation: I still didn't implement the possibility of overriding the default normaliser, described by https://testing-library.com/docs/queries/about/#normalization, which reads:
Before running any matching logic against text in the DOM, DOM Testing Library automatically normalizes that text. By default, normalization consists of trimming whitespace from the start and end of text, and collapsing multiple adjacent whitespace characters within the string into a single space.
That's because IMHO, this behaviour will already fits the vast majority of use cases. Please do let me know if you think differently, and I'll adjust this PR!
Thank you! 🚀
@lexanth , @pagevault-michael , any feedback on merging this? ;)