Remove numbers from document

Use Regular expressions to remove numbers from document. Use the following expression to catch all numbers

^[0-9]*            # All numbers that start a the beginning of the line

Test drive it on Rubular

What will the following regular expression do?

^([0-9]| )*

Answer: This will catch all numbers and spaces at the start of the line.

Another Example:
What will this regular expression do?

^ *[0-9]+

Answer: It will catch all numbers that start at the beginning of line, even the line starts with space character.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s