[Solved] Regular Expressions pattern to extract particular digits from text [closed]


Try this:

\b(?:256\d{9}|07[17-9]\d{8})\b

Explanation:

<!--
\b(?:256\d{9}|07[17-9]\d{8})\b

Options: ^ and $ match at line breaks; free-spacing

Assert position at a word boundary «\b»
Match the regular expression below «(?:256\d{9}|07[17-9]\d{8})»
   Match either the regular expression below (attempting the next alternative only if this one fails) «256\d{9}»
      Match the characters “256” literally «256»
      Match a single digit 0..9 «\d{9}»
         Exactly 9 times «{9}»
   Or match regular expression number 2 below (the entire group fails if this one fails to match) «07[17-9]\d{8}»
      Match the characters “07” literally «07»
      Match a single character present in the list below «[17-9]»
         The character “1” «1»
         A character in the range between “7” and “9” «7-9»
      Match a single digit 0..9 «\d{8}»
         Exactly 8 times «{8}»
Assert position at a word boundary «\b»
-->

solved Regular Expressions pattern to extract particular digits from text [closed]