Grep

The following command prints all the lines of the file input which contains a number

cat input | grep '[0-9]*'

Example:
Assume that the input has the following content:

axes12
w143th
qwer

Then the given command prints the following ouput:

axes12
w143th


Now change the command slighly so that it prints only the number part of the lines.


Example:
Assume that the input has the following content:

axes12
w143th
qwer

Then your new command should ouput the following content

12
143
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Grep on Interview Code Editor
Sign Up
to access hints and editorial solutions for Grep

Discussion


Loading...
Click here to start solving coding interview questions