For the PBK1234567890 number, you need to create a regular template to add to the beginning of 7, if the number does not begin with PBK and consists of 10 digits (ie 1234567890), then add 7 to the beginning (it should turn out 71234567890). But do not add 7 if the number starts with PBK. I compiled a template, but I cannot complete the logic (the bundle And for two groups does not work and perhaps the expression DOES NOT start correctly): s / ^ (! PBX) (\ d {10,}) / 7 $ 2 / g

  • one
    And why the condition on the PBX, if the basic condition is 10 digits and so does not work if the line does not start with 10 digits. those. just s/^(\d{10,})/7$1/ and by the way, why at the end of g ? - Mike
  • Well, yes it is logical. Type match. Thanks for the tip. g is like global. - Dima Kuzmin
  • Yes, g is global, which would make several replacements in the string. But you have a replacement tied to the beginning of the line. there can be only one, so it is not needed. I just saw him suspecting that maybe everything is more complicated ... - Mike

1 answer 1

Regular expression pattern: s / ^ (\ d {10}) $ / 7 $ 1 /