Sunday, January 12, 2020

Denver Travel Guide – Recommendations on Luxury & Budget Hotels near Attractions



The Colorado Capital, Denver comes with a seriously stunning backdrop of Rocky Mountains to the west of it and High Plains to its east, sitting in the South Platte River Valley. While you are in this American metropolis, observe the city’s oldest block, features landmark of 19th-century buildings at the Larimer Square or the ultramodern complex known for its collection of indigenous works, and the mansion of famed Titanic survivor Molly Brown at the Denver Art Museum. So whether you arrive here for a vacation trip with family or friends or a business trip you should take some time to research the best hotelsin Denver.

Denver International Airport (DEN) also referred to as DIA, is the primary international airport serving the city. A few decent hotel recommendations close to the airport include The Westin DEN International Airport, Fairfield Inn & Suites DEN Airport Marriott, Stay Bridge Suites DEN International Airport, and Best Western plus DEN International Airport Inn & Suites.

There are some non-negotiable attractions that you must visit while you are here. Explore places like the Air & Space Museum, Molly Brown House Museum, Coors Field, Botanic Gardens, American Museum of Western Art, Mile High Stadium, Mile High, Mount Evans, Larimer Square, Public Library, Colorado State Capitol, Downtown Aquarium, Children’s Museum of Denver, Forney Transportation Museum, Adams Mystery Playhouse, Bass Pro Shops Outdoor World, Museum of Nature & Science, Rocky Mountain Hot Air, Hammond’s Candy Factory, Union Station, Stranahan's Colorado Whiskey distillery tour, and B’s Ballpark Museum.

Where to Stay in Denver for Sightseeing?

To help you save your time in the beautiful Mile High City of Colorado, we have listed some of the best hotels and Resorts with easy access to the cities best attractions.

Budget Hotels

If you're on a budget and don't want to burn a hole in your pocket, that's fine we have found some of the best budget hotels near attractions. Some of the decent recommendations include  DoubleTree By Hilton Hotel Stapleton North, Clarion Hotel Central, Radisson Hotel Central, Renaissance Stapleton Hotel, Hyatt Regency Tech Center, La Quinta Inn by Wyndham Cherry Creek, Embassy Suites Tech Center North, and Hilton Garden Inn Tech Center to name a few.

Luxury Hotels

The Ritz Carlton, Four Seasons Hotel, Kimpton Hotel Born, The Brown Palace Hotel and Spa an Autograph Collection, JW Marriott at Cherry Creek, The Jacquard an Autograph Collection, Gaylord Rockies Resort & Convention Center, Renaissance Downtown City Center Hotel, Magnolia Hotel a Tribute Portfolio Hotel, Le Méridien Downtown, and Sheraton Downtown Hotel. All the above mention highly rated properties are the top accommodation option that you may look for.

Where to get the best deals on Denver Hotels & Flights to Denver? Explore TravOpedia where you can compare rates and amenities for different properties. You can read the reviews of the guest who stayed there in the past or look into the images of the properties or research over the location of the property on maps or even videos of the property & their surroundings. If you are looking for Last Minute Hotel Deals Denver or cheap flights to Denver, explore TravOpedia to get online promotional codes by exploring the web & that will help you save large. 

Monday, January 6, 2020

Mazatlán Travel Guide – Recommendations on Hotels near Attractions


Since the stars of Hollywood’s golden age came down for fishing trips and to socialize on Plaza Machado, Mazatlán has become a honeypot for foreign tourists. With a wide range of attractions, activities, and resorts, this majestic Mexican city attracts an abundance of travelers year-round. The coastal city in Sinaloa has a lot for its visitors, whether you stay in the modern Zona Dorada (Golden Zone), where there are a luxury marina and high-rise beachfront condos or you might prefer the Centro Histórico, first laid out in the 1830s and blessed with the prettiest sights. Getting hotels in this Mexican city is not a difficult task, so whether you arrive here for a vacation trip with family or friends, you should take the time to research the best hotelsin Mazatlan.

Mazatlán International Airport (MZT) commonly referred to as General Rafael Buelna International Airport is the primary airport to fly here. A few decent hotel recommendations close to the airport include Las Villas by Estrella del Mar and Hotel La Palapa.

There are some non-negotiable attractions that you must visit while you are here. Explore places like Aguachile, Whale Watching, Carnaval, do some Surfing, Playa Bruja, Las Labradas, Isla De La Piedra, Playa Olas Altas, Ángela Peralta Theatre, Immaculate Conception Cathedral, Faro, Malecón, Plaza Machado, and Centro Histórico to name a few.

Where to Stay in Mazatlán for Sightseeing?

To help you save your time in this beautiful city of Mexico, we have listed some of the best hotels and Beachfront resorts with easy access to the best diving and snorkeling spots and other tropical attractions.

Budget Hotels

If you're on a budget and don't want to burn a hole in your pocket, that's fine we have found some of the best budget hotels in Mazatlán near the beach. Some of the decent recommendations include Best Western Hotel Posada Freeman Zona Dorada, Best Western Hotel Posada Freeman Centro Historico, Royal Villas Resort, Holiday Inn Resort Mazatlan, El Cid Castilla Beach, El Cid Granada Hotel & Country Club, and Las Flores Beach Resort.

Luxury Hotels

Isla Mazatlan Residence Club, the local Hotels Mazatlán, Torrenza Boutique, Casa Lucila Hotel Boutique, Coral Island Beach View Hotel, El Cid Granada Hotel & Country Club-ALL INCLUSIVE, Olas Altas Inn Hotel & Spa, Ocean View Beach Hotel, and Costa de Oro Beach Hotel. All the above mention highly rated properties are the top accommodation option that you may look into it.

Where to get the best deals on Mazatlan Hotels? Explore TravOpedia where you can compare rates and amenities for different properties. You can read the reviews of the guest who stayed there in the past or look into the images of the properties or research over the location of the property on maps or even videos of the property & their surroundings. If you are looking for Last Minute Hotel Deals Mazatlan, explore TravOpedia to get online promotional codes by exploring the web & that will help you save large.

Friday, January 3, 2020

How To Care For Your Windows


uPVC windows and doors are the latest fads in integrated townships, standalone apartments, mansions, as well as in offices and business centers. People prefer to install uPVC profiles that get into sync into the themes of their interior and exterior. For this reason, people also order for customizations and designer uPVC products from leading uPVC windows dealers. However, after a few days of fenestration, the real problem starts as dust and dirt start to accumulate in the uPVC profiles. Also, the products react differently to different weather conditions.

As compared to other material and frames, uPVC windows are easy to clean and maintain. As a reputed uPVC windows manufacturer, Window Magic offers international quality uPVC products that incur extremely fewer maintenance costs. The uPVC windows guarantee of rigidity, sturdiness, strength, finish, and vinyl that does not scratch off easily. The glass of the windows does not accumulate dust. Even if there is a layer of dirt or stains, a casual swipe of cloth. This would give the window a fresh new look. Many households have toddlers, who playfully try to scratch the sills and sash. They often also make marks with crayons. These windows are extremely easy to clean and retain their classy finish, and factory paint even after years.

uPVC window suppliers most often recommend Window Magic for its contemporary look and best-in-class quality products that are bound to suit all kinds of home and office styles. They also do not require regular cleaning. However, use of a few cleaning liquids is recommended while things like abrasive sponges, soaps, detergents are discouraged in order to keep the windows in perfect shape. The windows must always be rinsed thoroughly during cleaning. It must always be remembered that the guidelines that come with the uPVC products should be followed for best results.

Oaxaca Guide – Recommendations on Hotels near Attractions


Located in the Centro District in the Central Valleys region and on the foothills of the Sierra Madre at the base of the Cerro Del Fortín extending to the banks of the Atoyac River, Oaxaca is a World Heritage city in southern Mexico. The city attracts an abundance of travelers year-round to visit its large number of colonial-era structures as well as the native Zapotec and Mixtec cultures and archeological sites. Getting hotels in this Mexican city is not a difficult task, so whether you arrive here for a vacation trip with family or friends, you should take the time to research the best hotels in Oaxaca.

Oaxaca International Airport (OAX) commonly referred to as Xoxocotlán International Airport is the primary airport to fly in here, some of the best hotels close to the airport include Maria Ines Hotel Suite, Hotel Guiva Aero Puerto, Motel Las Mara villas, Fiesta Inn, Hotel Hacienda, and Hotel Boutique Casa Garay.

Home of the month-long cultural festival Guelaguetza, featuring Oaxacan dance from the seven regions, music and a beauty pageant for indigenous women, Oaxaca has a lot to offer to its visitors. Whether you want to spend a few good hours at the Monte Albán to explore its pyramids or appreciate the treasures discovered in one of its tombs at Oaxaca’s Museo de las Culturas, every minute spent in this cultural city will drive your curiosity to explore more and more. There are some non-negotiable attractions that you must visit while you are here. Explore places like Monte Albán, Museo De Las Culturas, Church Of Santo Domingo De Guzman, Museo Rufino Tamayo, Zócalo, Árbol Del Tule, Plaza De La Danza Oaxaca, Museo Textil, The Cathedral, Jardín Etnobotánico, Mitla, Mercado Benito Juárez, Ex-Monastery Of Santiago Apóstol, Hierve El Agua, and Mole Negro to name a few.

Where to Stay in Oaxaca for Sightseeing?

To help you save your time in this beautiful city of Mexico, we have listed some of the best hotels and resorts with easy access to the best tourist attractions.

Budget Hotels

If you're on a budget and don't want to burn a hole in your pocket, that's fine we have found some of the best budget hotels for you. Some of the decent recommendations include Hotel CasAntica, Suites Bello Xochimilco, Hotel NaNa Vida, Mari Alicia Suites Hotel Boutique, La Catrina de Alcala, and Hotel Casa Vertiz.

Luxury Hotels

Casa Hotel Carmen, Hotel La Casona De Tita, Hotel Los Am antes, Quinta Real Oaxaca, Palacio Borghese, El Callejón Hotel Boutique, Hotel Siglo XVII Art Gallery, Casa Bonita Hotel Boutique & Spa, Hotel Hacienda Los Laureles, and Hotel Boutique Parador San Miguel Oaxaca. All the above mention highly rated properties are the top accommodation option that you may look into it.

Where to get the best deals on Oaxaca Hotels? Explore TravOpedia where you can compare rates and amenities for different properties. You can read the reviews of the guest who stayed there in the past or look into the images of the properties or research over the location of the property on maps or even videos of the property & their surroundings. If you are looking for Last Minute Hotel Deals Oaxaca, explore TravOpedia to get online promotional codes by exploring the web & that will help you save large.        

Cheap Hotels in Mexico City Guide to the Most Affordable Accommodation Options throughout the City


Since it's the capital of Mexico and known for its Templo Mayor (a 13th-century Aztec temple), the baroque Catedral Metropolitana de México of the Spanish conquistadors and the Palacio Nacional, which houses historic murals by Diego Rivera. Mexico City is filled to the edge with hotels, inns, hostels, and every type of accommodation available. It's a hub for both international business and tourism. There is such a wide range of accommodation that you should be able to find a place to stay despite your budget. Cheap hotels in Mexico City are found in every neighborhood, including the downtown area and surrounding areas.

Hilton Mexico City Reforma is a four-star hotel in Avenida Juarez, which gets a lot of positive ratings and facilitates its guests with amenities like Free Internet, Swimming Pool, Fitness Center, Business Center and much more. You might also be interested in the Galeria Plaza Reforma nested on Hamburgo 195, which features a Business Center, Non Smoking rooms, Fitness Center, Swimming Pool, Free Internet, Meeting & Banquet Facilities, and much more. The best part about these hotels is that even though they're highly rated luxury hotels but are available for a very affordable price.

If you're a vacation traveler or simply want to stay close to the attractions, there is the four-star Hotel Zocalo Central, which is a short walk next to the National Cathedral, where Montezuma’s Palace once stood. While staying here travelers can explore nearby attractions including the Fine Arts Palace or Alameda Park within a short 10-minute walk. A few amenities include Free Internet in Public Areas & rooms, Free Parking, Currency Exchange, Non Smoking rooms, and 24-Hour Front Desk. Some cheap hotels in the downtown area include Hotel San Francisco Centro Historico, Hotel Templo Mayor, Hotel Imperial Reforma, etc. The great thing about many of these hotels is that even though they're cheap, they're still pretty nice.

If you're a business traveler or simply want to stay near the Trade center, there are some decent options like the Courtyard by Marriott Revolucion, which is a short walk to the Trade Center. Its highlights include a Business Center, a Fitness Center, Free Parking, and Free Internet in Public Areas & rooms.

Apart from these recommendations, there are some other decent properties that you may consider, Grand Fiesta Americana Chapultepec, Sheraton Maria Isabel, City Express La Raza, NH Collection Reforma, Fiesta Inn Centro Historico, Hotel Villa del Mar, Holiday Inn Express Basilica, Hotel Villa de Madrid, and Fairfield Inn & Suites by Marriott Vallejo.

Where to get the best deals on Mexico City Hotels ? Explore TravOpedia where you can compare rates and amenities for different properties. You can read the reviews of the guest who stayed there in the past or look into the images of the properties or research over the location of the property on maps or even videos of the property & their surroundings. If you are looking for Last Minute Hotel Deals Mexico City, explore TravOpedia to get online promotional codes by exploring the web & that will help you save large.             


The Top Three Things to Do in Paris & Recommendations where to stay.


Named and Famed for the global center for art, fashion, gastronomy, and culture, Paris has a wide range of activities and attractions for its visitors. The city is also known for its cafe culture and designer boutiques along the Rue du Faubourg Saint-Honoré. Getting Hotels in Paris is not a difficult task, if it's your first time in Paris, you'll probably want to spend some time in these charming attractions listed below.

Cathedrale de Notre Dame de Paris (Notre-Dame Cathedral)

Located right along the picturesque River Seine, the Notre-Dame Cathedral is seen as a Parisian icon like the Eiffel Tower. Construction of the famous cathedral started in the late 10th century and final touches weren't made until nearly 200 years later and now is considered a Gothic masterpiece and is often regarded as one of the best Gothic cathedrals of its kind in the world. A few decent hotels close to the Cathedrale de Notre Dame de Paris include Holiday Inn Paris Notre Dame, Best Western Le Jardin de Cluny, Hotel de Nesle, Grand Hotel Saint Michel, and Citadines Saint-Germain-Des-Prés Paris


Musée du Louvre

Louvre is not only widely considered to be one of the best art museums in Europe, but one of the best in the world as well and if you only had time to visit one museum in Paris, it should undoubtedly be the Musée du Louvre. You'll find a total of 35,000 works of art and you can get up close to a variety of art from different periods and cultures including everything from Egyptian mummy tombs to ancient Grecian sculptures. You'll also find thousands of paintings to peruse and Masterpieces such as "Liberty of Leading the People" by Eugene Delacroix, "The Raft of Medusa" by Théodore Géricault and Leonardo da Vinci's "Mona Lisa," the museums biggest star, can be found here.

Eiffel Tower

Designed and constructed for the 1889 Exposition Universelle, the Eiffel Tower was always meant to be a temporary structure, but today Eiffel Tower stands as one of the most visited tourist attractions in the world. Travelers can walk up to the first floor of the Eiffel Tower or take the elevator up to the top, where they'll be treated with vast panoramic views of the city. If you want to stay close to the majestic Eiffel, a few decent hotel recommendations include Mercure Paris Centre Tour Eiffel, Ibis Paris Tour Eiffel Cambronne 15ème, Novotel Paris Centre Tour Eiffel, and Pullman Paris Tour Eiffel.

Where to get the best deals on Paris Hotels & Flights to Paris ? Explore TravOpedia where you can compare rates and amenities for different properties. You can read the reviews of the guest who stayed there in the past or look into the images of the properties or research over the location of the property on maps or even videos of the property & their surroundings. If you are looking for Last Minute Hotel Deals Paris or Cheap Flights to Paris, explore TravOpedia to get online promotional codes by exploring the web & that will help you save large.

Friday, July 15, 2016

Regular Expressions Guide for SEO, Google Analytics & Google Tag Manager

Regular Expressions Guide for SEO, Google Analytics & Google Tag Manager


I am going to explain the building blocks of Regular Expression (or REGEX), so that you can understand them and use them in technical SEO, in Google Analytics and Google Tag Manager.
Advantages of using REGEX in SEO:
1. You can convert long ugly dynamic URLs into SEO friendly URLs.
2. You can apply correct redirects.
3. Prevent people from hotlinking your images
4. Block spam bots
5. Resolve canonical URL issues
6. Resolve duplicate content issues (to an extent)
7. Deliver geo specific contents based on the IP address
Advantages of using REGEX in Google Analytics & Google Tag Manager:
1. Set up complex goals in Google Analytics like the one which could match multiple goal pages.
2. Set up complex funnel pages in Google Analytics like the one which could match multiple web pages.
3. Exclude traffic from a IP address range via Google Analytics filters
4. Set up complex advanced segments like the segments which can filter out branded keywords.
5. Understand the commercial value of long tail keywords.
6. Rewrite URLs in Google Analytics reports
7. Filter data based on complex patterns within the GA report interface.

What is Regular Expression?

It is an expression which is used to check for a pattern in a string.
For e.g. ^Colou?r$ is a regular expression which matches both the string: ‘color’ and ‘colour’. A regex is made up of characters and metacharacters.
Note: The regex used in this article are for JavaScript.

What are Metacharacters?

These are the characters which have special meaning in regex. They are the building blocks of a regex.
For e.g. [], ^, (), {}, $, +, * etc.

Building Blocks of a Regular Expression



Other Meta characters in Regex



Escaping Character – back slash \

‘\’ is the escaping character which is used to escape from the normal way a subsequent character is interpreted.
Though escaping character you can convert a regular character into meta character or turn a meta character into a regular character. 
For example:
Forward Slash (/) has a special meaning in regex. It is used to mark the beginning and end of a regular expression.
For example:
var a = /colou?r/;
If you want regex to treat forward slash as a forward slash and not some special character then you need to use it along with the escaping character like this: \/
So if you want to check for a pattern say /shop/ in the string /shop/collection/men/
then your regex should be: \/shop
If you use the regex /shop then it won’t match the string /shop/collection/men/ because / would be treated as a special character instead of a regular forward slash.
Another example:
n’ is a regular character. But if you add escaping character before it then it would become a meta character: \n which is a new line character.
So if you want to check for a pattern say /n in the string abcd\n3456
then your regex should be: abcd\\n3456
If you use the regex abcd/n then it won’t match the string abcd\n3456 because \n would be treated as a newline character instead of a regular character.
Another example:
?‘ is a meta character. To make it a regular character, you need to add escaping character before: \?
So if you want to check for a question mark in the string colou?r
then your regex should be: colou\?r
If you use the regex colou?r then it would match the string color or colour and not colou?r as then ? will be treated as meta character.


Caret  ^

^’ – This is known as ‘Caret’ and is used to denote the beginning of a regular expression.
^\/Colou?r => Check for a pattern which starts with ‘/Color’ or ‘/Colour’. Example:
/Colour/?proid=3456/review
/Color-red/?proid=3456/review
^\/Nov(ember)? => Check for a pattern which starts with ‘/Nov’ or ‘/November’. Example:
/November-sales/?proid=3456/review
/Nov-sales/?proid=3456/review
^\/elearning\.html => Check for a pattern which starts with ‘/elearning.html’. Example:
/elearning.html/?proid=3456/review
^\/.*\.php => Check for a pattern which starts with any file with .php extension. Example:
/elearning.php/color/?proid=3456/review
/games.php/?proid=3456/
/a1.php/color/?proid=3456&gclid=153dwf3533
^\/product-price\.php => Check for a pattern which starts with ‘/product-price.php’. Example:
/product-price.php?proid=123&cid=2142
/product-price.php?cid=2142&gclid=442352df

Caret also means NOT when used after the opening square bracket.
[^a] => Check for any single character other than the lowercase letter ‘a’.
For example: the regex product-[^a] will match:
/shop/men/sales/product-b
/shop/men/sales/product-c
[^B] = > Check for any single character other than the uppercase letter ‘B’.
For example: the regex product-[^B] will match:
/shop/men/sales/product-b
/shop/men/sales/product-c
[^1] => Check for any single character other than the number ‘1’.
For example: the regex proid=[^1] will match:
/men/product-b?proid=3456&gclid=153dwf3533
but will not match:
/men/product-b?proid=1456&gclid=153dwf3533
[^ab] => Check for any single character other than the lower case letters ‘a’ and ‘b’.
For example: the regex location=[^ab] will match:
/shop/collection/prodID=141?location=canada
but will not match:
/shop/collection/prodID=141?location=america
/shop/collection/prodID=141?location=bermuda
[^aB] => Check for any single character other than the lower case letter ‘a’ and uppercase letter ‘B’.
[^1B] => Check for any single character other than the number ‘1’ and uppercase letter ‘B’
[^Dog] => Check for any single character other than the following: uppercase letter ‘D’, lowercase letter ‘o’ and lowercase letter ‘g’.
For example: the regex location=[^Dog] will match:
/shop/collection/prodID=141?location=canada
/shop/collection/prodID=141?location=denmark
but will not match:
/shop/collection/prodID=141?location=Denver
/shop/collection/prodID=141?location=ontario
/shop/collection/prodID=141?location=greenland
[^123b] => Check for any single character other than the following characters: number ‘1’, number ‘2’, number ‘3’ and lowercase letter ‘b’.
[^1-3] => Check for any single character other than the following: number ‘1’, number ‘2’ and number ‘3’.
For example: the regex prodID=[^1-3] will match:
/shop/collection/prodID=45321&cid=1313
/shop/collection/prodID=5321&cid=13442
but will not match:
/shop/collection/prodID=12321&cid=1313
/shop/collection/prodID=2321&cid=1313
/shop/collection/prodID=321&cid=1313
[^0-9] => Check for any single character other than the number.
For example: the regex de\/[^0-9] will match all those pages in the de/ folder whose name doesn’t start with a number:
/de/school-london
/de/general/
but will not match:
/de/12fggtyooo
[^a-z] => Check for any single character which is not a lower case letter.
For example: the regex de\/[^a-z] will match all those pages in the de/ folder whose name doesn’t start with a lower case letter:
/de/1london-school
/de/?productid=423543
but will not match:
/de/school/london
[^A-Z] => Check for any single character which is not a upper case letter.

Dollar  $

$’ – It is used to denote the end of a regular expression or ending of a line. For e.g.
Colou?r$ => Check for a pattern which ends with ‘Color’ or ‘Colour’
Nov(ember)?$ => Check for a pattern which ends with ‘Nov’ or ‘November’
elearning\.html$ => Check for a pattern which ends with ‘elearning.html’
\.php$ => Check for a pattern which ends with .php
product-price\.php$ => Check for a pattern which ends with ‘product-price.php’

Square Bracket  []

‘[]’ – This square bracket is used to check for any single character in the character set specified in []. For e.g:
[a] => Check for a single character which is a lowercase letter ‘a’.
[ab] => Check for a single character which is either a lower case letter ‘a’ or ‘b’.
[aB] => Check for a single character which is either a lower case letter ‘a’ or uppercase letter ‘B’
[1B] => Check for a single character which is either a number ‘1’ or an uppercase letter ‘B’.
[Dog] => Check for a single character which can be anyone of the following: uppercase letter ‘D’, lower case letter ‘o’ or lowercase letter ‘g’.
[123b] => Check for a single character which can be anyone of the following: number ‘1’, number ‘2’, number ‘3’ or lowercase letter ‘b’.
[1-3] => Check for a single character which can be any one number from 1, 2 and 3.
[0-9] => Check for a single character which is a number.
[a-d] => Check for a single character which can be any one of the following lower case letter: ‘a’, ‘b’, ‘c’ or ‘d’.
[a-z] => Check for a single character which is a lower case letter.
[A-Z] => Check for a single character which is a upper case letter.
[A-T] => Check for a single character which can be any uppercase letter from ‘A’ to ‘T’.
[home.php] => Check for a single character which can be anyone of the following characters: lowercase letter ‘h’, lowercase letter ‘o’, lowercase letter ‘m’, lowercase letter ‘e’, special character ‘.’, lower case letter ‘p’, lowercase letter ‘h’ or lowercase letter ‘p’
Note: if you want to check for a letter regardless of its case (upper case or lower case) then use [a-zA-Z]

Parenthesis ()

()’ – This is known as parenthesis and is used to check for a string. For e.g.
(a) => Check for string ‘a’
(ab) => Check for string ‘ab’
(dog) => Check for string ‘dog’
(dog123) => Check for string ‘dog123’
(0-9) => Check for string ‘0-9’
(A-Z) => Check for string ‘A-Z’
(a-z) => Check for string ‘a-z’
(123dog588) => Check for string ‘123dog588’
Note: () is also used to create and store variables. For e.g. ^ (.*) $

Question mark  ?

‘?’ is used to check for zero or one occurrence of the preceding character. For e.g.
[a]? => Check for zero or one occurrence of lowercase letter ‘a’.
[dog]? => Check for zero or one occurrence of lowercase letter ‘d’, ‘o’ or ‘g’.
[^dog]? => Check for zero or one occurrence of a character which is not the lowercase letter ‘d’, ‘o’ or ‘g’.
[0-9]? => Check for zero or one occurrence of a number
[^a-z]? => Check for zero or one occurrence of a character which is not a lower case letter.
^colou?r$ => check for color or colour.
^Nov(ember)28(th)?$ => check for ‘nov 28’, ‘november 28, Nov 28th and November 28th
Note: ? when used inside a regular expression makes the preceding letter or group of letters optional.
For e.g. the regular expression: ^colou?r$ matches both ‘color’ and ‘colour’. Similarly, the regular expression: ^Nov(ember)28(th)?$ matches: ‘nov 28’, ‘november 28, Nov 28th and November 28th

Plus  +

‘+’ is used to check for one or more occurrences of the preceding character. For e.g.
[a]+ => Check for one or more occurrences of lowercase letter ‘a’.
[dog]+ => Check for one or more occurrences of letters ‘d’, ‘o’ or ‘g’.
[548]+ => Check for one or more occurrences of numbers ‘5’, ‘4’ or ‘8’.
[o-9]+ => Check for one or more numbers
[a-z]+ => Check for one or more lower case letters
[^a-z]+ => Check for one or more characters which are not lowercase letters.
[a-zA-z]+ => Check for any combination of uppercase and lowercase letters.
[a-z0-9]+ => Check for any combination of lowercase letters and numbers.
[A-Z0-9]+ => Check for any combination of uppercase letters and numbers.
[^9]+ => Check for one or more character which is not the number 9.

Multiply *

*‘ is used to check for any number of occurrences (including zero occurrences) of the preceding character.
For example, 31* would match 3, 31, 311, 3111, 31111 etc.

Dot .

‘.’ is used to check for a single character (any character that can be typed via keyboard other than a line break character (\n)).
For example the regular expression: Action ., Scene2 would match:
  • Action 1, Scene2
  • Action A, Scene2
  • Action 9, Scene2
  • Action &, Scene2
but not
  • Action 10,Scene2
  • Action AB,Scene2

Pipe |

‘|’ is the logical OR . For example:
(His|Her) => Check for the string ‘his’ or ‘her’.
His|Her => Check for the string ‘his’ or ‘her’. For example, the regex his|her will match:
  1. this is his book
  2. this is her book
  3. his or her
  4. her or his

Exclamation !

‘!’ – It is a logical NOT. But unlike ^ (caret), it is used only at the beginning of a rule or a condition. For e.g.
  1. (!abc) => Check for a string which is not the string ‘abc’.
  2. [!0-9] => Check for a single character which is not a number.
  3. [!a-z] => Check for a single character which is not a lower case letter.

Curly Brackets {}

{} is used to check for 1 or more repeat occurrence of the preceding character.
For example:
1{1} => check for 1 repeat occurrence of the character  ‘1’. This regex will match 1
1{2}  => check for 2 repeat occurrences of the character  ‘1’. This regex will match 11
1{3} =>check for 3 repeat occurrences of the character  ‘1’. This regex will match 111
1{4}  => check for 4 repeat occurrences of the character  ‘1’. This regex will match 1111
1{1,4}  =>check for 1 to 4 repeat occurrences of the character  ‘1’. This regex will match 1,11, 111, 1111
[0-9]{2}  => check for 2 repeat occurrences of a number or in other words, check for two digits number like 12
[0-9]{3}  => check for 3 repeat occurrences of a number or in other words check for three digits number like 123
[0-9]{4} => check for 4 digits number like 1234
[0-9]{1,4} => check for 1 to 4 digits number.

[a]{1} => check for 1 repeat occurrence of the character  ‘a’. This regex will match a
[a]{2}  => check for 2 repeat occurrences of the character  ‘a’. This regex will match aa
[a]{3} =>check for 3 repeat occurrences of the character  ‘a’. This regex will match aaa
[a]{4}  => check for 4 repeat occurrences of the character  ‘a’. This regex will match aaaa
[a]{1,4}  =>check for 1 to 4 repeat occurrences of the character  ‘a’. This regex will match a,aa,aaa,aaaa
[a-z]{2}  => check for 2 repeat occurrences of a lower case letter. This regex will match aa, bb, cc etc
[A-Z]{3}  => check for 3 repeat occurrences of a upper case letter. This regex will match AAA, BBB, CCC etc
[a-zA-Z]{2} => check for 2 repeat occurrences of a letter (doesn’t matter whether it is upper case or lower case). This regex will match aa, aA, Aa, AA etc
[a-zA-Z]{1,4} => check for 1 to 4 repeat occurrences of a letter (doesn’t matter whether it is upper case or lower case). This regex will match aaaa, AAAA, aAAA, AAAa etc

(rock){1} => check for 1 repeat occurrence of the string ‘rock’. This regex will match: rock
(rock){2} => check for 2 repeat occurrence of the string ‘rock’. This regex will match: rockrock
(rock){3} => check for 3 repeat occurrence of the string ‘rock’. This regex will match: rockrockrock
(rock){1,4} => check for 1 to 4 repeat occurrence of the string ‘rock’. This regex will match: rock, rockrock, rockrockrock, rockrockrockrock

White Spaces

To create a white space in a regular expression, just use the white space. For e.g.
(Himanshu Sharma) => Check for the string ‘Himanshu Sharma’

Inverting regex in JavaScript

Inverting a regex means inverting its meaning. You can invert a regex in JavaScript by using positive and negative lookaheads.
Use positive lookahead if you want to match something that is followed by something else.
Use negative lookahead if you want to match something not followed by something else.
Positive Lookahead starts with (?= and ends with )
Negative Lookahead starts with (?! and ends with )
For example: the regex de\/[^a-z] will match all those pages in the de/ folder whose name doesn’t start with a lower case letter:
/de/1london-school
/de/?productid=423543
but will not match:
/de/school/london
The invert of this regular expression would be: match all those pages in the de/ folder whose name starts with a lower case letter:
For example: the regex de\/(?![^a-z]) will match:
/de/school/london
but will not match:
/de/1london-school
/de/?productid=423543
Note: JavaScript only support lookaheads and not lookbehind. Google analytics doesn’t support either lookahead or lookbehind.

More Regex Examples

^(*\.html)$ => Check for any number of characters before .html and store them in a variable.
^dog$ => Check for the string ‘dog’
^a+$ => Check for one or more occurrences of a lower case letter ‘a’
^(abc)+$ => Check for one or more occurrences of the string ‘abc’.
^[a-z]+$ => Check for one or more occurrences of a lower case letter.
^(abc)*$ => Check for any number of occurrences of the string ‘abc’.
^a*$ => Check for any number of occurrences of the the lower case letter ‘a’

#. Find all the files which start from ‘elearning’ and which have the ‘.html’ file extension
^elearning* \.html$
#. Find all the PHP files
^*\.php$

mod_rewrite

It is a module (function) written in ‘C’ programming language: ‘mod_rewrite.c’. This module works only with Apache server 1.2 or later and is called from the .htaccess file (ASCII file which contains configuration directives and rules for files and folders). Through this module you can:
  1. Re-Write URLs
  2. Redirect URLs
  3. Solve Canonical URL issues
  4. Solve Hot linking issues
  5. Block visitors from accessing a particular folder, file or the whole website.
  6. Create custom 403 and 404 pages.
  7. Deliver contents on the basis of the IP address and benefits are end less.

Types of Configuration Directives

There are 9 types of configuration directives:
  1. RewriteEngine
  2. RewriteOptions
  3. RewriteLog
  4. RewriteLogLevel
  5. RewriteLock
  6. RewriteMap
  7. RewriteBase
  8. RewriteRule
  9. RewriteCond
But here we will talk about only three directives: RewriteEngine, RewriteRule and RewriteCond. I have not found any use of other directives so far.

RewriteEngine

This configuration directive is used to enable or disable the mod-rewrite module.
Syntax: RewriteEngine on/off
Default Value: RewriteEngine off
That’s why in .htacess file we first enable the mod-rewrite module by adding the following code:
Options +FollowSymLinks
RewriteEngine on

RewriteRule

This configuration directive tells the server to interpret the given statement as a rule.
Syntax: RewriteRule <pattern> <substitution> [FLAGS]
Here pattern is a regular expression and substitution is a URL.
FLAGS can be [R], [F], [NC], [QSA], [L], [OR] etc.

[R] =>
Redirect. Its default value is 302. It can be assigned any number from 300 to 400. For e.g.
RewriteRule ^index\.html$ /index.php [r=301]

[F] =>
Forbidden. It is generally used with hyphen (-). The hyphen tells the server not to perform any substitution. This flag tells the server not to fulfill the request and return ‘403’ response code. For e.g.
RewriteRule ^product-price\.php$ -[F]

[NC] =>
It tells the server to ignore uppercase or lowercase when checking for patterns. For e.g.
RewriteRule ^him*\.php$ [nc]

[QSA] =>
Query String append. It tells the server to pass query string from the original URL to the new URL.
[L] => Last rule. This tag tells the server not to process any more rules.
[OR] => Logical OR. This flag is used as logical OR for RewriteCond statements.

RewriteCond

This configuration directive tells the server to interpret the given statement as a condition for the rule which immediately follows it.
Syntax:

Here first mod-rewrite matches each URL with the given pattern. If no URL matches the pattern, then mod_rewrite process the next rule. If a URL matches the pattern, then mod_rewrite looks for the corresponding RewriteCond. If no corresponding RewriteCond exist, then the matched URL is replaced by the substitution.
If corresponding RewriteCond exist, then each RewriteCond is processed in the order they appear from top to bottom. Each RewriteCond is processed by matching its test string to against its corresponding condition pattern. If test string doesn’t matches with its condition pattern, then mod_rewrite process the next rule, otherwise it process the next RewriteCond. When all RewriteConds are successfully processed, then the matched URL is replaced by the substitution. A test string can be:
1. A simple text
2. RewriteRule back reference
3. RewriteCond back reference
4. Server Variable

RewriteRule Back Reference
It is of the form $N, where N can be any number from o to 9. It is used to denote that variable which was created in the RewriteRule pattern. For e.g.
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond Back Reference
It is of the form %N, where N can be any number from 1 to 9. It is used to denote that variable which was created in the ‘condpattern’ from the last matched ‘RewriteCond’. For e.g.
RewriteCond %{HTTP_HOST} ^(123\.42\.162\.7)$
RewriteCond %1 ^123\.42\.162\.7$
RewriteRule ……………..

Server Variable
Syntax: % {Variable_Name}
E.g.
1. %{HTTP_HOST} – This variable gives information about server name and its IP address.

2. %{HTTP_USER_AGENT} – This variable gives information about user’s operating system and browser.

3. %{QUERY_STRING} – This variable returns query string.
4. %{HTTP_REFERER} – This variable returns the URL of the referer.

5.%{REMOTE_ADDR} -This variable returns the IP address of the referer.


Examples

Example-1: Redirect all request for pages in the media folder to a new page ‘media.html’.
RewriteRule ^media/$ /media.html [r=301,l]
Example-2: Redirect oldaddress.html page to newaddress.html page
RewriteRule ^oldaddress\.html$ /newaddress.html [r=301,l]
Example-3: Redirect one website to another
Redirect 301 https://www.anotherwebsite.com
Example-4: Redirect abc.com/index.html to www.abc.com
RewriteCond %{REQUEST_URL} ^index\.html$
RewriteRule ^(.*)$ https://www.abc.com/$1 [r=301, l]
Example-5: Block a visitor from the IP address 12.34.56.78 to view your file product-prices.html
RewriteCond %{REMOTE_ADDR} ^12\.34\.56\.78$
RewriteRule ^product-prices\.html$ /sorry.html -[F]
Example-6: Block a visitor from the IP address 12.34.56.78 to view your folder ‘sales-demo’
RewriteCond %{REMOTE_ADDR} ^12\.34\.56\.78$
RewriteRule ^sales-demo/$ /sorry.html -[F]
Example-7: Block a visitor from the IP address 12.34.56.78 to view your website www.abc.com
RewriteCond %{REMOTE_ADDR} ^12\.34\.56\.78$
RewriteRule ^.*$ / -[F]
Example-8: Apply 301 from one file to another file
Redirect 301  /file1.html   https://www.mywebsite.com/file2.html  
The above code will permanently redirect file1.html to file2.html. So whenever a search engine or a visitor will look for file1.html, he will automatically be redirected to file2.html.
Example-9: Convert Dynamic URL into Static Looking SEO friendly URL
RewriteCond   % {QUERY_STRING}   ^keyval\=25\&Keyval2\=62$ [nc]
RewriteRule   ^productdescription.php$  https://www.example.com/whiteboard-accessories.php? [r=301, l]
This code will redirect https://www.example.com/productdescription.php?keyval=25&keyval2=62 to https://www.example.com/whiteboard-accessories.php
Note: You need to put question mark (?) at the end of the substitution URL, otherwise query string will be appended at the end of the substitution URL.
Example-10: Redirect non-www to www
rewritecond %{http_host} ^mywebsite.com [nc]
rewriterule ^(.*)$ https://www.mywebsite.com/$1 [r=301,nc]
Note: Replace ‘mywebsite’ by your website name
Example-11: Create Custom 404 page
Create a web page which you want to display as your custom 404 page say custom404.php and then upload your webpage to the root directory. Now add following code to your .htaccess file:
Options +FollowSymLinks
RewriteEngine on
ErrorDocument 404 https://www.mywebsite.com/custom404.php
Example-12: Block an IP address from accessing your website
Add following code in your .htaccess file:
Options +FollowSymLinks
RewriteEngine on
Order Deny, Allow
Deny from 61.16.153.67
If you want to block two or more IP addresses:
Options +FollowSymLinks
RewriteEngine on
Order Deny, Allow
Deny from 61.16.153.67
Deny from 124.202.86.42
Example-13: Resolve the Hot Linking Issue
Hot-linking means direct linking to your website file (images, videos etc). By preventing hot-linking, you can save your sever bandwidth. Add following code in your .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^https://(.+\.)?mywebsite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpg|jpeg|gif|bmp|png|swf)$ – [F]
Replace ‘mywebsite’ by your website name and then use hotlinking checker tool to find out whether your files (images,videos etc ) can be hot-linked or not.
Example-14: Enable proxy caching for static resources
Add following code to your .htaccess file
<FilesMatch “\.(gif|jpe?g|png)$”>
Header set Cache-Control “public”
</FilesMatch>

Regular Expressions and Google Analytics

There are many cases where regular expressions are very useful in Google Analytics. Some of such cases are:
1. Setting up a goal which should match multiple goal pages instead of one.
2. Setting up a funnel in which a step should match mutiple pages instead of one. Infact when you set up a funnel, all URLs are treated as regular expressions.
3. Excluding traffic from a IP address range via filters. Infact there are many filters which require regular expressions. Big organizations generally own a range of IP addresses. Therefore to exclude organization’s internal traffic you need to specify a IP range using regex.
4. Setting up advanced segments. For example following regex can segment all the traffic coming from social media sites:
twitter\.com|facebook\.com|linkedin\.com|plus\.google\.com|t\.co|bit\.ly|reddit\.com
Note: You can use Regex equipped advanced segments to unleash the power of the long tail keywords and determine whether these keywords are worth chasing. You can also use regex to segment important data through advanced segments.
5. Rewriting URLs in Google Analytics reports.
You can rewrite URLs in Google Analytics reports with ‘search and replace’ advanced filter. This comes handy when your website has very long ugly dynamic URLs and you can’t figure out what the page is all about just by looking at its URL. So for example with ‘Search & Replace’ advanced filter you can ask GA to report the following URL:
https://www.abc.com/fder/?catg=2341&pid=428
as
https://www.abc.com/outdoor/fleeces
6. Filtering data within the GA report interface.
You can use following regular expressions to filter keywords on the Google Analytics reporting interface:
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){0}$ =>Filter 1 word keyword phrase
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){1}$ =>Filter 2 words keyword phrase
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){2}$ =>Filter 3 words keyword phrase
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){3}$ =>Filter 4 words keyword phrase
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){4}$ =>Filter 5 words keyword phrase
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){5}$ => Filter 6 words keyword phrase
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){6}$ => Filter 7 words keyword phrase
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){7}$ => Filter 8 words keyword phrase
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){8}$ => Filter 9 words keyword phrase
^[^\.\s\-]+([\.\s\-]+[^\.\s\-]+){9}$ =>Filter 10 words keyword phrase
^([^ ]+ ){4,10}[^ ]+$ – Filter keywords that have between 4 to 10 spaces in them. This regex can help you in determining long tail keywords on your website.
^/([^/]+/){3}[^/]*$ – Filter landing pages that that have 4 slashes in their URL. This regex can help you in identifying low quality pages on your website.
Related Tools:
  1. To learn more about regular expressions: https://www.regular-expressions.info/
  2. The Regex Coach is a graphical application for Windows which can be used to test regular expressions
  3. Regular Expression Checker – chrome add-on to text regex

.htaccess

It is an ASCII file which contains configuration directives and rules for files, folders and the whole website. You can have more than one .htaccess file on a server. In fact you can have one .htaccess file per folder/directory. When you put the file in a directory, the rules mentioned in it are applicable only to all the files and sub-directories in the directory. When you put the file in the root directory, the rules mentioned in it are applicable to all the files and directories on the server. A htaccess file must contain following two lines:
Options +FollowSymLinks
RewriteEngine on