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