Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

mdHighlightText - Should allow to highlight string in the middle of the text #1799

Closed
carab opened this issue Mar 5, 2015 · 3 comments
Closed
Assignees
Milestone

Comments

@carab
Copy link

carab commented Mar 5, 2015

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 !

@ThomasBurleson ThomasBurleson modified the milestone: 0.9.0 Mar 12, 2015
@jgoux
Copy link

jgoux commented Apr 2, 2015

I need to search on multiple words, so I'd need this behaviour too. 👍

@robertmesserle robertmesserle added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Apr 2, 2015
@robertmesserle
Copy link
Contributor

@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?

@ajoslin ajoslin removed the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Apr 3, 2015
@lillylykho
Copy link

Hi! It's great! +1

thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants