I
I
Igor2019-03-18 12:25:01
Java
Igor, 2019-03-18 12:25:01

How to use regular expressions to replace multiple occurrences of non-consecutive characters?

1. Given a card number:
1234 5678 9999 0000
What is the best way to convert it to:
**** ***** ***** 0000
Using only regular expressions?
2. A random string is given, for example: It is
ABC123PPE553QQ999
necessary to replace the first five digits , for example:
ABC***PPE**3QQ999
Do I understand correctly that it is impossible to do this using regular expressions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Moskus, 2019-03-18
@Moskus

Why is the second one not possible?
Are looking for
replace with
The first five capture groups are filled with either nothing or any number of non-digits. Last - the remainder of the line after the last digit. It is assumed that there are always at least five digits in a string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question