Interview Questions

Q. You have a large file where you want to replace a lot of variable names. Fore example

Jon skeet
Alan Bradley
Micheal Moore

There are 500 entries. You want to remove the last name, how will you you do?

A. I will use regular expressions. Something like this
Find : [space].+
Replace: [empty string]

Q. In question 1 above, lets say you want to insert a dash(-) between first and last name, can yo do it?

A. Yes. It depends one different editors. In textmate I can use
Find: [space].+
Replace: – $0

$0 contains the whole string that was found using regular expression.

Advertisements
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