Level 9 : What is the output of the following code?


import re
num = '(212)-123-1234'
pattern = '\D'
result = re.sub(pattern, '',num)
print(result)

Author: anusha | Tags: regular-expression | 1859+ Python FAQs | Share
operator-and | objects | loop-control-statements | tuple | memory | type_conversion | yield | type-conversion-and-casting | string-slicing | virtual-environment | min-function | while-else-loop | methods | regular-expression | time-series-with-pandas | multithreading | mathematics | operator | list-comprehension | strings | map-function | loop | string-slicing | magic-method | rollback | while-and-for-loop | working-with-binary-files-(rb,-wb) | id-function | sets | benefit | encapsulation | conditional-statement | binary-operation | list-slicing | expand-tab | deep-copy | class-and-object | for | design-principle | namespace | file-handling | exception | async | numpy | why-use-multiprocessing-over-threading?-(gil) | append | complex | nested-loop | access-modifier | goto-function | function-argument | global | multiprocessing | asyncio | format | print-statement | matrix-list-comprehension | package-management | generator | compute | virtual-environment | variable | functional-programming | generators-in-python | list-mutation | factorial-function | file_handling | file-handling | dictionary-comprehensions | round | update | encoding | random-function | list-vs-tuple | shallow-copy | turtle | sys-module | escape-operator | indexing:-loc-vs-iloc | context-manager | list,-set,-and-dictionary-comprehensions | lambda-functions | loop-control | expression | __all__-attribute | version | docstring | using-the-threading-module | operator-overloading | identity-operator | __init_subclass__ | quantifiers-(*,-+,-?,-{}) | conditional-statements | datetime.date,-datetime.time,-datetime.datetime | exponentiation | exception-handling | assignment-operators | mapping-function | class-and-inheritance | filter | dictionary | filtering-and-indexing | data-structures-in-python | control-flow | reading-and-writing-large-files-efficiently | math | indentation | lambdas | unit-testing | list-operation | regex | syntax | indexing | split | immutable-data-type | control-statement | pseudocode | error | string-formatting | test-discovery | using-lists-as-stacks | zip-function | string-iteration | managing-directories-with-os-and-shutil | binary | type-conversion | working-with-temporary-files-using-tempfile | swapping | gil | min-max-function | built-in-modules | def | sorting-and-ranking | list | overflow | global-variable | round-function | pickling--unpickling | mysql | join | typeerror | control-flow | mutable | boolean-and-non-boolean | error-handling | thread-synchronization | list-methods-and-slicing | zfill-function | method | python-operators | arbitrary-arguments-(*args,-**kwargs) | default-mutable-argument | intering | string-methods | keyword | function-and-scope | sum-function | inheritance | recursion | else-statement | data-type | parameter | multiple-inheritance | introduction-to-multiprocessing | math-copysign | identifier | call | immutability | filter-function | stack | booleans | multiple-except-blocks | comment | built-in-function | python_version | dataframe-and-series-objects | statement | pass | set | center | python-module | name-mangling | decorator | classes | software-design | debugging | bitwise | reading:-read(),-readline(),-readlines() | data-type-conversions | iterator | functions | recurssion | list-comprehension | multiple-inheritance | touples | object-attribute | string-formatting | module | data-structure | pep | operators | identity-operator | regular-expressions | working-with-file-paths | list-method | thread | tuple-unpacking | creating-custom-modules | data-type | lists | logical-operator | fabs-function | floating-point-precision | file | string-manipulation | reading-and-writing-files | while-loop | using-join()-and-is_alive()-methods | class | data-structures | oops | zip | generators | using-assertions-(assertequal,-assertraises) | handling-missing-values-(fillna,-dropna) | lambda-function | counter-function | thread-safe-data-structures-(queue.queue) | int | directory-operations | loops | choice | introduction-to-python | type-conversion | condition | command-line-parsing | key-value-pairs | slicing | raise-statement | odd-number | counter | invalid-list | anchors-(^,-$) | global-keyword | data-structure | using-yield-in-functions | string-concatenation | bitwise-operator | complex-number | scientific-notation | basic | joining-and-merging-dataframes | logical-operator | python | built-in | floats | class-and-instance-variable | while-loops | else | return-statement | formatting-with-strftime | inherit | array | collection | print | default-arguments | dictionary-methods | writing:-write(),-writelines() | bitwise-operator | collections | datetime | enumerate() | assert | built-in-function | tuples | head-and-tail | slice | implementation | descriptors | literal-characters-and-special-characters | arithmetic-operation | boolean-masking | set-operation | integers | data-types | postfix | assignment-operator | using-map()-for-transformations | syntax-error | asyncio-module | membership-operators-(in,-not-in) | using-os-and-pathlib-modules | input-function | match | string-method | using-else-and-finally | creating-and-starting-threads | class-decorators | precedence-and-associativity | list-join | single-inheritance | __future__ | list-comprehensions | constructor | introduction-to-threads | comprehension | boolean | python-django | application | logical-operators | opening-files-(open()) | python-history | interpreter | comparison | matplotlib | random | arithmetic-expression | difference-between-threads-and-processes | operator-or | parsing-with-strptime | syntaxerror | method-overloading | datatype | string | working-with-dates-and-times | memory-management | logical-operation | destructor | sys | threading | functional-programming | staticmethod | polymorphism | static-method | operand | library | sorting | pandas | oop | advanced-file-operations | attribute | tuple-methods | string-method | sum() | namedtuple | copy | integer | iterable | walking-through-directories-using-os.walk() | input | dicts | conditional-statement | syntax-error | overriding-methods | input-function | data_structure | defining-functions | dictionaries | decimal | iterators | sorted | python-syntax-and-structure | aggregating-data-with-functools.reduce() | matrix | import-method | error-handling | version-check | lambda | feature | higher-order-function | function | heap-memory | installation | frozenset | list-indexing | numeric | exception-handling | init | with-statement | mathematical-function | max-min | operations | python-repl | formal-and-actual-parameter | precedence | global-variable | raise | identity-operators-(is,-is-not) | conversion | range ...