Examples: Replacing Text

These examples all use UNIX extended regular expression syntax.

1. Find any alphabetic word starting with an upper case letter:
and replace with the same word all in upper case:

2. Find a C language variable name starting with a lower case letter:
\<[a-z][ a-zA-Z0-9]*
and make the first letter upper case:

3. Find two numeric strings separated by one or more spaces:
\([0-9]+\) +\([0-9]+\)
and swap them around, using a tab to separate them:

4. Find “paste”:
and replace with the contents of the clipboard:

5. To change:
X100000 to X100.000
Y100123 Y100.123
Z600 Z.600
Find: \([XYZ]\)\([0-9]*\)\([0-9][0-9][0-9]\)
Replace: \1\2.\3


Leave a Reply

Please log in using one of these methods to post your comment:

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

%d bloggers like this: