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