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