Text Editor - Find Text Using Regular Expressions

It’s in our muscle memory. Press Ctrl+F in your favorite text editor to find something, provide find criteria, and hit the Find button. As always, we usually stick with the simple Find functionality of the text editor as it serves almost all of our basic search needs. But beneath Find dialog box, there is a powerful Find option, Use Regular Expressions which most seldom use.

Visual Studio 2019 - Find in Files

Able to recall a correct regular expression when we need it most is rare. Which often leads to the hassle of googling regular expression and trying few failed attempts, and going back to simple Find. This is where following regular expressions cheatsheet comes handy for me.

Regular Expressions:

  • Have foo anywhere and bar later in the same line

    .*foo.*bar

  • Have foo at the beginning of the line

    ^\s{2,}foo

  • Have foo at the beginning of the line and bar later in the same line

    ^\s{2,}foo.*bar

  • Have foo in the commentted line

    .*//.*foo

  • Have foo inside double quotes

    ^.*".*foo.*"

  • Have foo at the beginning or end of the word

    ^.*".*\bfoo.*"

  • Have foo at the end of the line

    foo\r?\n

  • Have foo); at the end of the line

    foo\);\r?\n

  • Have foo but not bar in the same line

    ^.*foo.*(?!bar)

  • Have foo and { in the next line

    .*foo.*\r?\n.*{

DataTable add column extension

Unfortunately there is no method to call DataTable.Add with the column size. This extension method will fix that:

1
2
3
4
5
6
7
8
public static DataColumn Add(this DataColumnCollection columns, string columnName, Type type, int maxLength)
{
  DataColumn column = new DataColumn(columnName, type);
  column.MaxLength = maxLength;
  columns.Add(column);

  return column;
}

iPhone - Scroll Bottom Bookmarklet

You can easily scroll to the top of the webpage by just tapping on the top bar ( the bar which has icons like signal status, carrier name, time etc.) of iPhone but how about scrolling to the bottom of the page? If you are browsing very long web page then sometimes it becomes a bit annoying to scroll through the whole page to get the bottom of the page. But here is a small Javascript hack, through which allow you to scroll to the bottom of the page with just one tab. You just require adding this Javascript code as a bookmarklet (or sometimes it also called Favelet):

Javascript Code:

1
javascript:(function(){scroll(0, document.body.scrollHeight);})();

Link: Scroll Bottom

To add Scroll Bottom bookmarklet, just drag above link to Safari Bookmarks Bar and then sync to your iPhone through iTunes.

Following are some relative articles for bookmarks and syncing to the iPhone:

Syncing iPhone and iPod touch with your computer
iPhone: Using Bookmarks
17 powerful bookmarklets for your iPhone