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, '#');
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.