I need to match a word like \'César\' for a regex like this /^cesar/i
.
Is there an option like /i
to configure the regex so it ignores the
In general it could by done easily with some help of Lodash library, when you're testing two types of the same regex input - one is deburred by lodash _deburr function other is raw user's input. Example for username input form based filtering (with little help of lodash _filter function):
import _ from 'lodash'
const input = inputFromYourFormInput
const users = ['Jiřina Žlutá', 'Aleš Úzký'];
const regex = new RegExp(input, 'gi');
const filtered = _.filter(users, (u) => {
const debured = _.deburr(u)
if (u.name.match(regex) || debured.match(regex))
return u
})
In this case It doesn't matter if your input is Jirina Zluta or Jiřina Žlutá _filter function will return new filtered array [Jiřina Žlutá]