Regular Expressions 101

Library entries

0
python

Author cite

Get author names from shitty import
Submitted by anonymous - 12 hours ago
0
python

Session Start/Close

Capturing Start/Close in IRC-logs
Submitted by Corpset - 8 days ago
0
python

PLDI regex 3

for pldi answer
Submitted by PlaceReporter99 - 9 days ago
0
python

PLDI regex 2

for pldi answer
Submitted by PlaceReporter99 - 9 days ago
0
python

PLDI regex 1

For pldi answer
Submitted by PlaceReporter99 - 9 days ago
0
python

Dyno warning regex

Used to separate things in dyno warning
Submitted by anonymous - 10 days ago
0
python

Hesla ISJ

ISJ
Submitted by anonymous - 11 days ago
0
python

100-4300

match 100, 200, 300 upto 4300
Submitted by anonymous - 12 days ago
1
python

Get <NIC>

Get NICs from string
Submitted by anonymous - 17 days ago
0
python

camel-assistnt resp

camel-assistnt resp
Submitted by anonymous - 23 days ago
0
python

langchain

langchain
Submitted by anonymous - a month ago
0
python

URL Pattern Django

URL Pattern Django
Submitted by Fernando Olivera - a month ago
0
python

walter1976FirstClean

walter1976FirstClean
Submitted by anonymous - a month ago
0
python

walter1976Split

walter1976Split
Submitted by anonymous - a month ago
0
python

auto-gpt command google

auto-gpt command google returned
Submitted by anonymous - a month ago

Get path from any text

Vote

0

Regular Expression
pcre2

/
(?############ Let's catch paths without "" or '' ############################ )(?<opening>(?# First, catch the starting path, the <opening> ################### )\b(?<montage>[a-zA-Z]:[\/\\])(?# montage = 'C:/' )|[\/\\][\/\\](?<!http:\/\/)(?<!https:\/\/)(?>(?# check not 'http[s]:' prefix )[?.][\/\\](?:[^\/\\<>:"|?\n\r ]+[\/\\])?(?# '//[?or.]/xxxxx' or '//[?or.]/server/' )(?&montage)?(?# '//[?or.]/c:/' or '//[?or.]/server/c:/' )|(?!(?&montage)))(?# '//[addressIP/ or serverName/ but not C:/]' )|%\w+%[\/\\]?(?# '%EnvVariable%[/]' ))(?# So, <opening> catch : 'C:/' or '//[?or.]/[UNC/]C:/' or '//[?or.]/[UNC/]' or '//[next characters must be something other than C:/]' or '%EnvironementVariable%[/]' )(?:(?# now, we catch each directory name wich is between [/] ######################## )[^\/\\<>:"|?\n\r ,'](?# the first character should not be [ ,'] )[^\/\\<>:"|?\n\r]*(?# Any pathFrendly character )(?<![ ,'])(?# The last directory name's character must not be [ ,'] )[\/\\](?# End of directory name - who are between '/' - ))*(?# Catch most 'directoryName/' as possible )(?:(?# Lets catch the End path. There is a file ? a directory ? or just a useless '/' ? )(?=[^\/\\<>:"'|?\n\r;, ])(?#if next character is not pathFriendly or ' ' or [,'], we have reach the end of the path => we don't catch the last '/' and the the Regex end now. You can't catch fileName who begin by [,'] because they are probably a delimiter between 2 path. but '.' is allowed )(?:(?#If we are here, that mean there is a fileName or directoryName to catch ###### We will catch the last directoryName or the fileName without the extention ###### )(?:[^\/\\<>:"|?\n\r;, .](?# catch any character pathFriendly exept ' ' or [,.] )(?: (?=[\w\-]))?(?# If we find a ' ', we catch him if next charcter is not a delimiter. I see '-' after an ' ' not like a delimiter. )(?:\*(?!= ))?(?# If we find a '*', we stop the catch if next character is an ' ' )(?!(?&montage))(?# If we find a string who look like 'C:/', we stop the catch ))+(?# We catch theses word delimited by ' ' as much as possible ))?(?# it's possible the fileName have no name, but just an extention )(?:\.\w+(?# #### an extention begin by '.' and at least one none delimiter chracter ))*(?# we can add more extention until the first none '.' delimiter character. So, after the first '.' character inside a fileName, we cannot catch any ' ' character If we don't find one extention, so the filename is a directory name, and we stop the catch. ))(?# ############# END OF PATH CATCHING WITHOUT QUOTE "" and '' ####################### )|(?:(?# ######### Catching path quoted '' ########################### Path quoted '' is difficult because ['] is also a pathFrendly character )'(?&opening)(?# We catch .* between quote only if string start with an <opening> )(?=.*'\W|.*'$)(?# We catch .* between quote only if we are sure we will find end quote. End quote must be ['] and delimiter character or ['] and end string )(?:[^\/\\<>:'"|?\n\r]+(?# We take any pathFriendly character exept quote ['] )(?:'(?=\w))?(?# we catch quote ['] if next character is not a delimiter )[\/\\]?)*(?# Path quoted must respect this patern until end quote character ['] )')(?# end quoted '' path )|(?# ######### Catching path quoted "" ########################### )"(?&opening)(?# We catch .* between quote only if string start with an <opening> )(?=.*")(?# We catch .* between quote only if we are sure we will find end quote ["] )(?:[^\/\\<>:"|?\n\r]+(?# We take any pathFriendly character )[\/\\]?(?# pathFriendly characters can be is delimited by '\' ))*(?# Path quoted must respect this patern until end quote character )"(?# end quoted path )
/
g

Description

Loading markdown...
Submitted by nitrateag - 4 months ago