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