Regex: mask all but the last 5 digits, ignoring non-digits -


I want to match interspersed spaces or hyphens with a number 17-23, then last with all Starr instead of five digits I can match the following regex:

  ((?: (?: \ D) ([\s -] *)) {12,18}) (\ d [\ s -] *) {5}   

My problem is that I can not get regex to group all the instances of [\ s -] in the first code , And I do not know how to get it to replace initial 12-18 digits with asterisk ( * ).

How about:

  s / \ d (? = (?: [-] * \ d! {- [*] * \ D)) / * / g   

A positive attitude reveals that the minimum At least 5 points ahead by matching points, while the embedded negative lookhead ensures that there are no more than 22.

However, there may be even more digits with pre-matched digits before this is, if there are 24 or more digits, it only works in the last 23 is. I do not know that this is a problem for you.

Comments