Apologies for the COMPLETELY DIFFERENT topic, but I spent a lot of time trying to format some stuff, so I’m recording this for next time I want to do this.
Step 1: place the curser near the text you want to align, and double click in the ruler bar area. A small black bent arrow should appear. It will probably point toward the right.
Step 2: double click on the arrow in the ruler bar. A dialog box should appear. Depending on how many tab stops you have, one or more numbers will appear in a list on the left under ‘Tab stop position’. Select the tab stop of interest. In my case, it was the second/last stop. To get the arrow to point toward the left/align the text on the right side of the document, click the ‘right’ selector under ‘Alignment’.
Step 3: Hit save. Drag the arrow to where you want to text to line up. Be happy!
- When a test is especially short or simple compared to the application code it tests, lean toward writing the test first.
- When the desired behavior isn’t yet crystal clear, lean toward writing the application code first, then write a test to codify the result.
- Because security is a top priority, err on the side of writing tests of the security model first.
- Whenever a bug is found, write a test to reproduce it and protect against regressions, then write the application code to fix it.
- Lean against writing tests for code (such as detailed HTML structure) likely to change in the future.
- Write tests before refactoring code, focusing on testing error-prone code that’s especially likely to break.
— Michael Hartl, Ruby on Rails Tutorial
One of the things that is kind of annoying about regular expressions is that every programming language implements them slightly differently. If you can, find someone who can give you the low-down in this new language. Otherwise, you’ll have to stick with googling, which can take a while to figure out what you need. I’ll get you started with a few languages.
Two of my favorite and most helpful resources:
Regular Expressions in Ruby
One of the easiest ways to get started with regular expressions in Ruby is via Rubular.com. This site provides a way to test regular expressions against any text, as well as a quick cheat sheet to help. RegExPlanet.com also has a Ruby tester that is in beta.
Regular Expressions in Java
For help with Java, I really like using the tester at RegExPlanet.com. It does two really cool things.
- Different Java methods (apparently) use regular expressions differently. RegExPlanet.com shows if and how a regular expression will work with each of the methods.
- RegExPlanet.com also provides the ‘Java string’ for use in Java methods. In Java, we have to escape the backslashes with additional backslashes. This can get pretty confusing very quickly, so having RegExPlanet.comgenerate that string for me is very helpful.
This regular expression will match the word ‘hello’ as well as capitalized ‘Hello’, and all caps ‘HELLO’. It will even match the super fancy ‘hElLo’, if you are into crazy stuff like that. The
i modifier tells the regular expression to be case-insensitive.
g modifier tells it to find ALL the instances where a string matches the given pattern.