Regular expression: Matching Whole Lines of Text

Matching Whole Lines of Text

Often, you want to match complete lines in a text file rather than just the part of the line that satisfies a certain requirement. This is useful if you want to delete entire lines in a search-and-replace in a text editor, or collect entire lines in an information retrieval tool.

To keep this example simple, let’s say we want to match lines containing the word “John”. The regex John makes it easy enough to locate those lines. But the software will only indicate John as the match, not the entire line containing the word.

The solution is fairly simple. To specify that we need an entire line, we will use the caret and dollar sign and turn on the option to make them match at embedded newlines. In software aimed at working with text files like EditPad Proand PowerGREP, the anchors always match at embedded newlines. To match the parts of the line before and after the match of our original regular expression John, we simply use the dot and the star. Be sure to turn off the option for the dot to match newlines.

The resulting regex is: ^.*John.*$. You can use the same method to expand the match of any regular expression to an entire line, or a block of complete lines. In some cases, such as when using alternation, you will need to group the original regex together using parentheses.

Finding Lines Containing or Not Containing Certain Words

If a line can meet any out of series of requirements, simply use alternation in the regular expression.^.*\b(one|two|three)\b.*$ matches a complete line of text that contains any of the words “one”, “two” or “three”. The first backreference will contain the word the line actually contains. If it contains more than one of the words, then the last (rightmost) word will be captured into the first backreference. This is because the star isgreedy. If we make the first star lazy, like in ^.*?\b(one|two|three)\b.*$, then the backreference will contain the first (leftmost) word.

If a line must satisfy all of multiple requirements, we need to use lookahead.^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$ matches a complete line of text that contains all of thewords “one”, “two” and “three”. Again, the anchors must match at the start and end of a line and the dot must not match line breaks. Because of the caret, and the fact that lookahead is zero-length, all of the three lookaheads are attempted at the start of the each line. Each lookahead will match any piece of text on a single line (.*?) followed by one of the words. All three must match successfully for the entire regex to match. Note that instead of words like\bword\b, you can put any regular expression, no matter how complex, inside the lookahead. Finally, .*$ causes the regex to actually match the line, after the lookaheads have determined it meets the requirements.

If your condition is that a line should not contain something, use negative lookahead. ^((?!regexp).)*$ matches a complete line that does not match regexp. Notice that unlike before, when using positive lookahead, I repeated both the negative lookahead and the dot together. For the positive lookahead, we only need to find one location where it can match. But the negative lookahead must be tested at each and every character position in the line. We must test that regexp fails everywhere, not just somewhere.

Finally, you can combine multiple positive and negative requirements as follows:^(?=.*?\bmust-have\b)(?=.*?\bmandatory\b)((?!avoid|illegal).)*$. When checking multiple positive requirements, the .* at the end of the regular expression full of zero-length assertions made sure that we actually matched something. Since the negative requirement must match the entire line, it is easy to replace the .* with the negative test.

PDF: Save adobe pdf zoom and scrolling settings

Adobe PDF File settings: Save adobe zoom and scrolling settings

Adobe preferences:

  1. Open Adobe Reader.
  2. Select “Edit” > “Preferences“.
    1. Documents tab->
      1. Open Settings–>“Restore last view settings when reopening documents” = checked
    2. Page Display tab–>Under the “Default Layout and Zoom” area,
      1. Change the “Zoom” dropdown menu to a desired setting.
      2. Page Layout: Single Page Continuous option. be sure to click the OK button at the bottom of the window when you are finished to apply the changes.
    3. Accessibility tab.
      1. If “Always use Zoom Setting” is selected, Reader will use the setting specified in the drop-down menu on this screen.
    4. Security (Enhanced) settings
      1. Uncheck: Enable protected mode at startup
      2. Uncheck: Enable Enhanced Security

PDF: Error while saving file – document could not be saved

When I try to save adobe pdf it gives me the error:

The document could not be saved. Cannot save to this filename. Please save the document with a different name or in a different folder.”


User experience this issue for files on network shares as well once Adobe Reader was updated to 11.0.10

It has to do with Protected Mode being turned on.  It could get turned on by adobe reader update – a prompt warning you if you want to overwrite the existing file & then selecting “Yes” to overwrite.


To disable Protected Mode:

Start Adobe Reader

Edit – Preferences – Security (Enhanced)

Uncheck Enable Protected Mode at Startup

Close Preferences & Close Reader



DSLR: First camera crash course: simple solutions for mastering your new DSLR


So you bought your first camera… now what do you do? If you’re struggling with your first steps in DSLR photography, rest assured you’re not alone. And we’re here to help.Whether you’ve just bought your first camera or just need to brush up on your shooting skills, we’ve got an all-in-one guide to getting to grips with your new DSLR.First camera crash course: simple solutions for mastering your new DSLR

We’ll start off this photographic crash course by explaining – in simple terms – how exposure works, so you can capture perfectly exposed shots every time with your first camera. We’ll show you the importance of choosing the best aperture and depth of field for different subjects.

We’ll also reveal all you need to know about shutter speed, for freezing subjects or capturing a sense of movement in your scene. And we’ll pass on expert advice for getting the best possible results with your first camera when the light is getting low.

Then we build up to focusing, to help you get sharp shots whatever you’re shooting, and how to avoid common autofocus pitfalls. We’ll round things off with a photo composition masterclass, explaining the best ways to approach and compose your shots.

First Camera Crash Course Lesson 1: Aperture explained

The two main elements you use to take an exposure are aperture and shutter speed. The aperture of a lens ranges from wide to narrow, and is measured in f/stops, such as f/4 (wide aperture) to f/22 (narrow aperture).

The wider the aperture, the more light is let in to reach your DSLR’s sensor – brightening your shots. The narrower the aperture, the less light is let in – darkening your shots.

Shutter speed, on the other hand, dictates the how long your DSLR’s shutter stays open for, and so also controls how much light reaches the sensor.

Aperture and shutter speed act in unison to determine your exposure, so a wide f/4 aperture and fast 1/500 sec shutter speed lets in the same amount of light as a narrow f/16 aperture and slow 1/30 sec shutter speed, giving an identical exposure. However, you may still end up with two very different shots…

First Camera Crash Course Lesson 1: Aperture explained

Wide aperture

  • When taking portraits, always make sure you focus on the eyes to draw people into the shot
  • A mid-range focal length of 55mm decreases the angle of view, as well as helping to further decrease depth of field (see top right)
  • Using a wide aperture of f/3.5 ensures your subject is sharp but the background is blurred, helping them stand out


First Camera Crash Course Lesson 1: using a narrow aperture

Narrow aperture

  • A wide-angle focal length of 18mm increases the angle of view and also increases DoF
  • A narrow aperture of f/16 has made sure the scene is sharp, from the rocks in the foreground to skyscrapers in the background
  • Use leading lines to draw the eye into your photos

What is depth of field?

When you change your lens’s aperture setting, you affect depth of field (DoF). The depth of field refers to the amount of your scene that’s acceptably sharp.

Using a wide aperture (such as f/5.6) will result in a ‘shallow’ depth of field. This is why wide apertures are ideal for shooting portraits and wildlife, as you can blur the backgrounds behind your subjects to really make them stand out in the scene.

Using a narrow aperture (such as f/16) results in a greater depth of field. This is why narrow apertures are perfect when shooting landscapes and cityscapes, as you want to ensure your scene is acceptably sharp from the foreground through to the background area.

Final tip
Use Aperture Priority mode to control your apertures. In this semi-auto mode, your DSLR will then set the shutter speed for a standard exposure.


10 common camera mistakes every photographer makes
How to use a camera: exposure modes made simple
99 common photography problems (and how to solve them)

15 common photography questions from beginners (and how to solve them)

First Camera Crash Course Lesson 2: using exposure compensation

Use Evaluative Metering mode to get a good starting point for your exposures. You can then brighten or darken them quickly using Exposure Compensation when shooting in Av (or Tv) mode.

Use the Av+/- button on the back of your DSLR and the top dial to set positive/negative exposure – using the Exposure Level Indicator in your viewfinder (or rear LCD) to dial in Exposure Compensation. Turn the dial to the right to brighten your shot, to the left to darken it.

First Camera Crash Course Lesson 2: using exposure compensation

This shot is underexposed – a common problem when photographing white scenes or subjects.


First Camera Crash Course Lesson 2: using exposure compensation

Use Exposure Compensation to brighten shots, but too much will result in it being overexposed, such as in this image.


First Camera Crash Course Lesson 2: using exposure compensation

By dialling in +1-stop of positive Exposure Compensation the shot is now well-exposed.

Pentaho/ Kettle (Spoon)

  1. install the jre7
  2. kitchen.bat file contains the configuration about the java home directory and pentaho data-integration home directory
  3. edit the ga_data.bat file
  4. edit the ga_data2.bat file
  5. edit the Get_P2P.bat
  6. edit the ga_data_job.kjb file using the spoon.bat file and also using notepad
  7. edit the ga_visit2_data_job.kjb file using the spoon.bat and also using notepad
  8. edit the P2P_Get_Data.kjb file using the spoon.bat and also using notepad
  9. edit the sql agent job: “dashboards data”
  10. edit the sql agent job: “New GA data”
  11. edit the sql agent job: “Get_P2P_Pages “
  12. Spoon–>Open the .kjb job file–> select the transaction step–>Right click–>Open referenced object–>Transformation. Then on the left pane, Explorer, you will see the Database connections option–>