Community Patterns

37

best youtube id match ( iframe embed replace ready )

Created·2019-03-12 16:17
Flavor·PCRE (Legacy)
Recommended·
MATCH ANY YOUTUBE ID author : mi-ca v1.0 – 2017.03.08 This Regex match any youtube url and grab the ID. Embed ready √ -- `http://www.youtube.com/watch?v=vpiMAaPTze8 http://youtu.be/l_la5XiQJdk http://youtu.be/NLqAF9hrVbY https://youtu.be/qT47KF5pvfw https://youtu.be/zImHyTyYhM8?t=4s http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US http://www.youtube.com/watch?v=NLqAF9hrVbY http://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/2/PPS-8DMrAn4 http://gdata.youtube.com/feeds/api/videos/NLqAF9hrVbY http://www.youtube.com/watch?v=spDj54kf-vY&feature=g-vrec http://www.youtube.com/watch?v=spDj54kf-vY&feature=youtu.be http://www.youtube-nocookie.com/watch?v=NLqAF9hrVbY http://www.youtube.com/embed/NLqAF9hrVbY https://www.youtube.com/embed/NLqAF9hrVbY https://www.youtube.com/watch?v=MRl7cxSOXdU&feature=youtu.be https://www.youtube.com/watch?v=q07SQFmL4rM https://www.youtube.com/watch?v=q07SQFmL4yM https://www.youtube.com/watch?time_continue=4&v=zImHyTyYhM8 http://www.youtube.com/embed/dQw4w9WgXcQ ... http://www.youtube.com/watch?v=dQw4w9WgXcQ ... http://www.youtube.com/?v=dQw4w9WgXcQ ... http://www.youtube.com/v/dQw4w9WgXcQ ... http://www.youtube.com/e/dQw4w9WgXcQ ... http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ ... http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/0/dQw4w9WgXcQ ... http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ ... http://www.youtube.com/?feature=player_embedded&v=dQw4w9WgXcQ ... https://www.youtube.com/watch?v=DFYRQ_zQ-gk&feature=featured https://www.youtube.com/watch?v=DFYRQ_zQ-gk http://www.youtube.com/watch?v=DFYRQ_zQ-gk //www.youtube.com/watch?v=DFYRQ_zQ-gk www.youtube.com/watch?v=DFYRQ_zQ-gk https://youtube.com/watch?v=DFYRQ_zQ-gk http://youtube.com/watch?v=DFYRQ_zQ-gk //youtube.com/watch?v=DFYRQ_zQ-gk youtube.com/watch?v=DFYRQ_zQ-gk https://m.youtube.com/watch?v=DFYRQ_zQ-gk http://m.youtube.com/watch?v=DFYRQ_zQ-gk //m.youtube.com/watch?v=DFYRQ_zQ-gk m.youtube.com/watch?v=DFYRQ_zQ-gk https://www.youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US http://www.youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US //www.youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US www.youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US https://www.youtube.com/embed/DFYRQ_zQ-gk?autoplay=1 https://www.youtube.com/embed/DFYRQ_zQ-gk http://www.youtube.com/embed/DFYRQ_zQ-gk //www.youtube.com/embed/DFYRQ_zQ-gk www.youtube.com/embed/DFYRQ_zQ-gk https://youtube.com/embed/DFYRQ_zQ-gk http://youtube.com/embed/DFYRQ_zQ-gk //youtube.com/embed/DFYRQ_zQ-gk youtube.com/embed/DFYRQ_zQ-gk https://youtu.be/DFYRQ_zQ-gk?t=120 https://youtu.be/DFYRQ_zQ-gk http://youtu.be/DFYRQ_zQ-gk //youtu.be/DFYRQ_zQ-gk youtu.be/DFYRQ_zQ-gk https://www.youtube.com/watch?v=DFYRQ_zQ-gk&feature=featured https://www.youtube.com/watch?v=DFYRQ_zQ-gk http://www.youtube.com/watch?v=DFYRQ_zQ-gk //www.youtube.com/watch?v=DFYRQ_zQ-gk www.youtube.com/watch?v=DFYRQ_zQ-gk https://youtube.com/watch?v=DFYRQ_zQ-gk http://youtube.com/watch?v=DFYRQ_zQ-gk //youtube.com/watch?v=DFYRQ_zQ-gk youtube.com/watch?v=DFYRQ_zQ-gk https://m.youtube.com/watch?v=DFYRQ_zQ-gk http://m.youtube.com/watch?v=DFYRQ_zQ-gk //m.youtube.com/watch?v=DFYRQ_zQ-gk m.youtube.com/watch?v=DFYRQ_zQ-gk https://www.youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US http://www.youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US //www.youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US www.youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US youtube.com/v/DFYRQ_zQ-gk?fs=1&hl=en_US https://www.youtube.com/embed/DFYRQ_zQ-gk?autoplay=1 https://www.youtube.com/embed/DFYRQ_zQ-gk http://www.youtube.com/embed/DFYRQ_zQ-gk //www.youtube.com/embed/DFYRQ_zQ-gk www.youtube.com/embed/DFYRQ_zQ-gk https://youtube.com/embed/DFYRQ_zQ-gk http://youtube.com/embed/DFYRQ_zQ-gk //youtube.com/embed/DFYRQ_zQ-gk youtube.com/embed/DFYRQ_zQ-gk https://youtu.be/DFYRQ_zQ-gk?t=120 https://youtu.be/DFYRQ_zQ-gk http://youtu.be/DFYRQ_zQ-gk //youtu.be/DFYRQ_zQ-gk youtu.be/DFYRQ_zQ-gk https://www.youtube.com/HamdiKickProduction?v=DFYRQ_zQ-gk `
Submitted by mi-ca.ch
19

Get path from any text

Created·2023-01-31 14:38
Updated·2023-07-23 20:17
Flavor·PCRE2 (PHP)
Recommended·
Get path (windows style) from any type of text (error message, e-mail corps ...), quoted or not. THIS IS THE SINGLE LINE VERSION ! If you want understand how it work or edit it, go https://regex101.com/r/7o2fyy Relative path are not supported The goal is to catch what "Look like" a path. See the limitations UNC path and prefix path like //./], [//?/] or [//./UNC/] are allowed some url path like [file:///C:/] or [file://] are allowed Catch path quoted with ["] and [']. But these quotes are include with the catch Quoted path is not concerned by limitations Limitations : (only unquoted path) [dot] and [space] is allowed, but not in a row [dot+space] or [space+dot at end of file name isn't catched INSIDE A NAME FILE (or last directory if it is a path to a directory) : [comma] is not supported (it stop the catch) after a first [dot], any [space] stop the catch after a [space], catch is stoped if next character is not a [letter], [digit] or [-] so, double [space] stop the catch Compatibility compatible PCRE, PCRE2 AutoHotkey : don't forget to escape "%" in "`%" /!\ Powershell and .Net /!\\ : this regex need some modification to be interpreted by powershell. You have to replace each (?&CapturGroupName) by \k. Use this powershell code to do this replacement : ` $powershellRegex = @' [Put here the regex to replace (?&CapturGroupName) with \k] '@ -replace '\(\?&(\w+)\)', '\k' ` This example code must return : [Put here the regex to replace \k with \k]
Submitted by nitrateag

Community Library Entry

1

Regular Expression
Created·2025-11-16 03:15
Flavor·PCRE2 (PHP)

/
^(?i).*?[_\- ]*(?:bad[-_ ]blood|smiley[_\- ]?in[_\- ]?high|smiley[_\- ]?blue[_\- ]?([^0-9_().-]+)).*?(\d*)?(\.ico)?$
/
gm
Open regex in editor

Description

The regular expression we are working with is: ^(?i).*?[_\- ]*(?:bad[-_ ]blood|smiley[_\- ]?in[_\- ]?high|smiley[_\- ]?blue[_\- ]?([^0-9_().-]+)).*?(\d*)?(\.ico)?$

Renaming Task:

Files needing renamed;

  • Bad-Blood-Emoji (1)1.ico
  • Bad-Blood-Emoji (2)2.ico
  • smiley_blue_eyesonfire3.ico
  • smiley_blue_nosepick4.ico
  • smiley_in_high7.ico

as you can see, there is a mix of naming styles & numbers.

GOAL (examples)

I want them renamed to something like;

  • Smiley-badblood(1)
  • Smiley-eyesonfire(2).ico
  • Smiley-nosepick(3).ico and etc?...

Batch method (recommended)

  1. Open the folder in Bulk Rename Utility and select those files.

  2. RegEx (1) — isolate the descriptor (removes trailing digits and other noise)

    • Match: ^(?i).?[_- ](?:bad[-_ ]blood|smiley[- ]?in[- ]?high|smiley[- ]?blue[- ]?([^0-9_().-]+)).?(\d)?(.ico)?$ (This is an example to show concept — you can simplify for your exact set; see notes below.)
    • Replace: \1\3
    • Check Inc. Ext. only if you need to include extension in matching (not required here).
    • Purpose: produce a cleaned descriptor (e.g. badblood, eyesonfire, nosepick, in_high -> inhigh or whatever normalized token you prefer).

    Note: crafting a single RegEx to perfectly normalize every variant can be fiddly. If your filenames follow a few patterns, you can run multiple Match/Replace pairs (RegEx editor) to map each pattern to a clean descriptor (see examples later).

  3. Case (4)

    • Mode: Title (or Lower then use other rules)
    • This can turn “badblood” → “Badblood” or you can instead use lower-case descriptor and keep “Smiley-” capitalized in the next step.
  4. Add (7)

    • Prefix: Smiley- (This will add the fixed "Smiley-" at start.)
    • Suffix: ) (we will create opening parenthesis via Numbering Sep, and closing paren here)
  5. Numbering (10)

    • Mode: Suffix
    • Start: 1
    • Incr.: 1
    • Pad: 0 (or use Pad 0/none)
    • Sep.: ( (Put a single "(" in Sep. so the numbering becomes "(1")
    • This plus the Add(7) suffix of ")" yields filenames that end with "(1)".
  6. Extension (11)

    • Mode: Same (keep .ico unchanged)
  7. Preview then Rename

    • Select the files, click Preview (or just see the New Name column), adjust steps if something looks wrong, then click Rename.

If your RegEx isn't perfect for extracting the descriptor, you can instead use a simpler multi-step approach that’s often easier:

Simpler multi-step approach (less regex, more GUI):

A. Remove digits at end

  • Remove (5) -> Chars: leave blank but enable Digits = checked (This will remove digits from the file name portion; extension .ico remains.)
  • Use Crop or Replace to remove the extraneous parentheses/numbers leftovers if needed.

B. Replace underscores and repeated words

  • Replace (3)
    • Replace: _
    • With: (a single space or dash depending on desired output)
  • Or use Replace to replace specific sequences (e.g., replace "Bad-Blood-Emoji" with "badblood").

C. Add Prefix

  • Add (7) Prefix = Smiley-

D. Normalize case

  • Case (4) -> Title or Lower as preferred; you can then tweak exceptions.

E. Numbering

  • Numbering (10) as above, Sep = "(" and Add(7) Suffix = ")"

Examples of multiple small RegEx replacements (use RegEx editor - easier than one huge regex):

  • Match: (?i)bad[-_ ]blood.?(\d) Replace: badblood
  • Match: (?i)eyesonfire.?(\d) Replace: eyesonfire
  • Match: (?i)nosepick.?(\d) Replace: nosepick
  • Match: (?i)smiley[- ]in[- ]high.?(\d) Replace: inhigh

Then run Add(7) Prefix = Smiley- and Numbering as above.

If you prefer the absolute simplest manual route (for 5 files):

  • Select each file and edit the New Name column directly (click it and type the desired name) or use Rename button after filling Name (2) -> Fixed per-file. For small lists this is often quickest.

Notes & tips

  • Use the RegEx editor (click the list icon) to put multiple Match/Replace rules so BRU will apply them in sequence.
  • Use the Preview / New Name column constantly to check results before doing the actual rename.
  • If you need descriptors all to be lower-case (e.g., badblood, eyesonfire), set Case -> Lower, then use Add(7) with Prefix "Smiley-" and Title-case the prefix if you want the leading S capitalized — easiest: put "Smiley-" as literal prefix (capital S) then set Case to Lower with Exceptions that keep "Smiley" capitalized is possible but fiddly; simpler is: Add Prefix "Smiley-" then set Case to "Same" or use formatters/tags for finer control.
  • To create the parentheses around the number: Numbering Sep = "(" and Add(7) Suffix = ")" produces ...name(1).ext
Submitted by J.Baker 42