Reputation: 4845
I have a $location.path()
that is of the following type of format:
/request/add/c3smsVdMHpVvSrspy8Vwrr5Zh8qSyP7q
I am interested in filtering the hash after /request/add/
to the following. As you can see, the last four chars are shown, but everything else before that is labeled as [FILTERED]
/request/add/[FILTERED]yP7q
I did some basic code which converts the hidden chars to #
, but I got stuck in trying to apply the string [FILTERED]
after the /request/add
.
old_path = $location.path()
path = old_path.replace(/.(?=.{4,}$)/g, '#');
Upvotes: 0
Views: 79
Reputation: 32511
You could use substring
. This will give you the [FILTERED]
contents then you can do whatever you'd like with them.
var old_path = '/request/add/c3smsVdMHpVvSrspy8Vwrr5Zh8qSyP7q';
var filtered = old_path.substring('/request/add/'.length, old_path.length - 4);
var path = old_path.replace(filtered, '[FILTERED]');
console.log(path);
Upvotes: 3