13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.2 Eye to Eye with vi431,$s/Tryout/Sample/gWill make the substituti<strong>on</strong> in that method name.TIPRemember to precede these commands with a col<strong>on</strong> (“:”) to put you into exmode which puts your cursor <strong>on</strong> the status bar of the window.2.2.3 The Joy of Regular Expressi<strong>on</strong>sThe substituti<strong>on</strong> command really becomes powerful when you start using regularexpressi<strong>on</strong>s. Our examples so far have <strong>on</strong>ly had plain alphanumeric charactersbetween the slashes of the substituti<strong>on</strong>. But other characters take <strong>on</strong> specialmeanings inside the search and replace strings. Table 2.1 shows just a few.From this small collecti<strong>on</strong> we can do some useful things. We show just afew in Table 2.2. All commands begin with :1,$ to say that the substituti<strong>on</strong>will be attempted from the first through the last line of the file. 3 You could usea smaller range for any of these substituti<strong>on</strong>s, as we discussed above.Table 2.1 Regular expressi<strong>on</strong> character meaningsCharacter^$.*+[]&MeaningThe beginning of the line.The end of the line.Any single character.Zero or more repetiti<strong>on</strong>s of the previous expressi<strong>on</strong>.One or more repetiti<strong>on</strong>s of the previous expressi<strong>on</strong>.Any of the characters inside the brackets will match—e.g., [abc] matches anyof a, b, c. Ranges are allowed too—e.g., [a-z].When used <strong>on</strong> the right-hand side, stands for whatever was found with thesearch string <strong>on</strong> the left-hand side (for an example, see Table 2.2).3. Note that % is valid substitute for 1,$.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!