mdHighlightText - Should allow to highlight string in the middle of the text
Hi everyone,
I started using mdAutocomplete in my project, and I was wondering how I could use mdHighlightText properly.
My problem is that this directive only highlights the given string if the text starts with it. Shouldn't it allow to highlight the string anywhere in the text ?
The easy fix would be to replace this :
var regex = new RegExp('^' + sanitize(term), 'i'),
By this:
var regex = new RegExp(sanitize(term), 'i'),
In the controller code (MdHighlightCtrl).
Actually, the best option would be to allow to use the same comparing function than the one that filters the items in mdAutocomplete... But maybe this will need to much change.
Thank you for your attention !
I need to search on multiple words, so I'd need this behaviour too. :+1:
@carab @jgoux The idea I have for how to handle this is to allow the user to specify flags, much the same way that JS RegExp handles them. e.g. g for global, i for case-insensitive, etc.
I would also add two extra flags: ^ for 'starts with' and $ for 'ends with'
Sound good?
Hi! It's great! +1
thanks