Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression

/
/
img

Test String

Code Generator

Generated Code

$re = '/<\s?[^\>]*\/?\s?>/im'; $str = 'Day 1 Bangkok.< br /> Welcome to South East Asia. Arrive into Bangkok today, where you\'ll be transferred to the centrally located Hotel. A pre-trip briefing will be held in the evening at 6pm to meet the other members of your group and to <br<<<>discuss the itinerary. Please check for a welcome notice on the Peregrine noticeboard located in the reception area of your hotel. The notice should provide the name of your trip leader, along with the exact time and location of the meeting. After the group meeting in the evening, perhaps adjourn<strong> to a nearby restaurant and enjoy a first meal together (this is optional and at your own expense). The rest of the<strong > evening < /strong / >is free to enjoy a quiet drink or visit the bustling night markets of Bangkok. Day 2 Chiang Rai. Today take the one-and-a-half-hour flight from Bangkok to Chiang Rai. This scenic town is a lot more relaxed than neighbouring Chiang Mai. Visit</html> the privately owned Wat Rong Khun, more commonly known as the White Temple. This contemporary temple is constantly being added to and its strange design features references to Buddhist mythology, human sin and pop culture > icons such as Michael Jackson, Harry Potter and Superman. In the evening visit the buzzing Chiang Rai night markets, where you can snack on delicious Thai cuisine or shop for souvenirs and handicrafts. Day 3 Pakbeng.<br > Today leave Chiang Rai before dawn to travel for around two hours to Chiang Khong. After crossing the border, take a shuttle bus across the Mekong River to Huay Xai, which is your first stop in Laos. Transfer to the pier and board a slow boat for the trip down the Mekong River. The pace is very relaxed - a perfect way to observe the scenery and local life up close. The private boat has toilets onboard, comfortable seats, dining tables and plenty of room to stretch your legs. In the evening arrive into Pakbeng, a village situated at the junction of the Mekong and Beng rivers. Hmong and tribal Thai people are frequently seen on the main street, where vendors sell local textiles and handicrafts. You will spend the night in a lodge right by the river. Before then, enjoy the memorable experience of a Baci Ceremony, organised as a welcome by the Chaman of Pakbeng and the people of the village. This is the perfect way to begin your journey into Laos, putting the spirits on your side. The ceremony aims to bring the 32 souls (khouan) that look after you back to your body and attract beneficial influences. The Baci ceremony is performed at all important events in a person\'s life. Notes Due to the remote location of Pakbeng, the accommodation tonight is of a lower standard than our usual Peregrine Hotels but still clean and comfortable. Day 4 Luang Prabang. Today continue down the Mekong River in your private slow boat, gaining more insight into local rural life along the way. Stop in at Pak Ou, where the famous Tam Ting Cave is home to thousands of Buddha statues. Continuing on, pay a visit to Ban Sang Hai village where potent rice wine is made. Travel time down the river varies greatly with the water level, but if all goes to plan you should arrive into Luang Prabang by early evening. This sacred town, with its gleaming temple roofs, French architecture and mountainous backdrop, is claimed to be \'the best preserved city in South East Asia\' by UNESCO. Day 5 Luang Prabang.<strong> In the morning, you may like to rise early to witness the daily procession of monks collecting alms from the villagers - a practice that dates back centuries. Following breakfast visit the town\'s major temples, including the magnificent Wat Xieng Thong. After the tour, walk around the local shops and find hand woven handicrafts.<strong> Next, visit the National</strong> Museum at the former Royal Palace, a building that combines French colonial and traditional Lao architecture. In the afternoon head south of town to the beautiful Kuang Si Falls. Back in Luang Prabang this evening, perhaps explore the popular night market or enjoy a traditional Laos massage. A late night in Luang Prabang isn\'t really an option, as the town observes a nightly curfew of 11.30 pm. Day 6 Luang Prabang. This morning you will visit a traditional Lao textile-weaving centre. You\'ll be taken by a guide through the centre and learn how this important project supports local Laotian artisan women and the community. The project is called Ock Pop Tok, or East Meets West, after its co-founders - a Laotian girl and English woman. The rest of the day is then free. There are many of optional activities to keep you busy. Perhaps try your hand at preparing some traditional Laotian food in a cooking class. You could visit the Traditional Arts and Ethnology Centre, a not-for-profit museum dedicated to promoting the diverse cultures and traditions of Laos\' ethnic groups. Guided tours and seminars are available on request. If you feel like getting active, why not climb the 328 steps up Mount Phu Si in the centre of Luang Prabang\'s old town? The hill is crowned by a gilded stupa, That Chomsi, where you can enjoy spectacular views over the town and surrounding forest. Afterwards, you may like to wind down with a traditional Lao sauna and massage at the massage parlour opposite Wat Visounnarat. Day 7 Vientiane. Today take a 45-minute flight from Luang Prabang to Vientiane. On arrival into the capital, your leader will take you on a short orientation walk so you can get your bearings. The friendly city of Vientiane features a lot of French-inspired architecture and cuisine, so ask your leader where to find the best bakeries. Day 8 Vientiane. Today embark on a tour around the major sights of Laos\' capital. Visit the imposing Patuxai monument, which is Vientiane\'s version of the Arc de Triomphe. Call in at the oldest temple in the city, Wat Si Saket, and the former royal temple of Haw Phra Kaew. This previously housed the famous Emerald Buddha image before the Siamese took it in the late 18th century. Discover the golden stupa of Pha That Luang, which is an important Buddhist monument and the national symbol of Laos independence. Tonight enjoy an included dinner at the Makphet Restaurant in Vientiane. Peuan Mit runs the restaurant, which is an organisation that supports the needs of street children and young people in Laos. Day 9 Vientiane. Your adventure ends after breakfast today. There are no activities scheduled so you\'re free to depart the accommodation at any time. A transfer to the airport is not included, however your tour leader will be able to advise you on the available options. '; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php