Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Faq ► FAQ - How-To ► ««« »»»

Search for/in text using regular expressions (Regex)?


Regular expressions (also called regex) are powerful tools to search for, extract or manipulate text patterns in strings. Here's an overview of how you can use regular expressions to search for text in different scenarios.




1. Search for a simple word
2. Search for a word regardless of case
3. Search for a pattern with wildcards
4. Search for a number
5. Search for a specific format (e.g. time)
6. Search for text in quotes
7. Search for a specific string with possible variations
8. Search for a string at the beginning of a line
9. Search for optional characters
10. List of the most important commands and symbols used in regular expressions





1.) Search for a simple word



Example: Search for the word "desktop"
Desktop
This will find every occurrence of the word "desktop".

2.) Search for a word regardless of case



Example: Search for "desktop" or "Desktop" or "DESKTOP"
(?i)desktop
The (?i) at the beginning makes the search case-insensitive.

3.) Search for a pattern with wildcards



Example: Search for "color" followed by any word
color\s\w+
This is:

- \s for a space

- \w+ for one or more alphanumeric characters.

4.) Search for a number



Example: Search for a number (e.g. a time)
\d+
The \d+ searches for one or more digits.

5.) Search for a specific format (e.g. time)



Example: Search for a time in the format "HH:MM"
\d{2}:\d{2}
This searches for two digits, a colon and two digits again.

6.) Search for text in quotes



Example: Search for everything in quotes
".+?"
This matches the content between quotes. The .+? means "any text in minimal match".

7.) Search for a specific string with possible variations


Example: Search for "Q-Dir" or "Quad File Explorer"

Q-Dir|Quad File Explorer

The | stands for "or".

8.) Search for a string at the beginning of a line



Example: Search for a string that is at the beginning of the line
^Quad File Explorer
The ^ stands for the beginning of the line.

9.) Search for optional characters



Example: Search for "clock" or "clocks"
Clock?
The ? after the character means that the previous character is optional.

10.) List of the most important commands and symbols used in regular expressions



Here is a list of the most important commands and symbols used in regular expressions (regex) to search for text patterns:

1. Character classes



- . : Any character except newline.

- \d : Digit [0-9].

- \D : No digit character.

- \w : Alphanumeric character (letter, number, or underscore).

- \W : No alphanumeric character.

- \s : Whitespace character (tab, space, etc.).

- \S : No whitespace.

2. Repetitions



- * : 0 or more repetitions of the previous character.

- + : 1 or more repetitions of the previous character.

- ? : 0 or 1 repetition of the previous character (optional).

- {n} : Exactly n repetitions.

- {n,} : At least n repetitions.

- {n,m} : Between n and m repetitions.

3. Anchor (position in text)



- ^ : Start of line.

- $ : End of line.

- \b : Word boundary (e.g. \bbeste\b only matches the word "beste" and not "bestes").

- \B : No word boundary.

4. Groups and alternatives



- ( ... ) : Brackets for groupings and priority.

- | : Or (e.g. best|hardware finds "best" or "hardware").

- (?: ... ) : Non-capturing group (prevents the expression from being captured as a group).

5. Escaping



- \ : Escape character to use special characters like . or * as a literal (e.g. \. looks for a dot).

6. Lookahead and Lookbehind (Looking Forward and Backward)



- (?= ...) : Positive lookahead - checks if a pattern is followed without capturing it (e.g. (?=.*\bbest\b) checks if "best" occurs somewhere later in the line).

- (?! ...) : Negative lookahead – checks if a pattern does not follow (e.g. (?!.*bad) ensures that "bad" does not follow).

- (?<= ...) : Positive lookbehind – checks if a pattern is present before (e.g. (?<=\bbeste\b) ensures that "best" occurs before).

- (?<! ...) : Negative lookbehind – checks if a pattern is not present before.

7. Options



- (?i) : Case-insensitive search (ignore upper/lower case).

- (?m) : Multiline mode – ^ and $ match the beginning and end of the line, not just the beginning and end of the entire text.

- (?s) : Dotall mode – the dot . also matches line breaks.

8. Examples



- \d{3}-\d{3}-\d{4} : Finds a phone number format like "123-456-7890".

- ^[A-Za-z]+$ : Finds a line that consists only of letters.

- \bhttps?://\S+ : Finds URLs that start with "http" or "https".

These commands will help you search virtually any type of text, from simple words to complex patterns. If you have any specific questions or use cases, let me know!



FAQ 45: Updated on: 7 September 2024 07:29 Windows
How-To

How do I proceed on a virtual platform machine?


The procedure on a platform virtual machine, such as that used when working with virtual machines VMs or virtual environments e.g. cloud platforms, can
How-To

How do I use the character map? How do I use the character map?


Everyone is familiar with opening the Character Map in Windows 11, 10, etc, but how do I use the Character Map on Microsofts Windows Desktop and Server
How-To

Empty or reset icon cache on Windows 11, 10, etc.!


The icon cache / temporary storage under Windows can lead to incorrect shortcut icons, here is the solution for deleting / resetting the icon cache on Windows
How-To

Open the printer queue folder in Explorer!


The printer queue folder can be opened and viewed under Windows 11, 10, or MS Server OS in the file explorer, the open print jobs are saved here Contents:
How-To

Show SVG thumbnails in Windows Explorer?


In order to display SVG thumbnails in Windows Explorer under Windows 11, 10, and MS Server, a shell extension for the operating system is required Preface:
How-To

Find out the command line of programs on Windows 11 and 10!


In the task manager you can easily find out the command line of programs, this is possible under Windows 11, 10, , for example to recognize the start

»»

  My question is not there in the FAQ
Asked questions on this answer:
Keywords: search, text, using, regular, expressions, regex, also, called, powerful, tools, extract, manipulate, patterns, strings, here, overview, Questions, Answers, Software




  

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks
  + Security

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + WinBin2Iso
  + ThisIsMyFile
  + TheAeroClock
  + Bitte.Wenden
  + CoronaKO
  + MatriX.CoronaKO
  + Find.Same.Images.OK
  + 3D.Benchmark.OK
  + PhotoResizerOK
  + PAD-s


Home | Thanks | Contact | Link me | FAQ | Settings | Windows 10 | gc24b | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2025 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu
30.31 msec.


► Uninstall Q-Dir from Surface Pro on Windows 10, how to? ◄
► Quad-File-Explorer Q-Dir Defender Firewall Win-10, problem! ◄
► Quad File Explorer Download Variants for Windows! ◄
► Short information about the memory modules on the computer! ◄


This website does not store personal data. However, third-party providers are used to display ads,
which are managed by Google and comply with the IAB Transparency and Consent Framework (IAB-TCF).
The CMP ID is 300 and can be individually customized at the bottom of the page.
more Infos & Privacy Policy

....