Regular Expressions 101

Community Patterns

22

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
1

LIMA

Created·2024-10-01 18:31
Flavor·PCRE2 (PHP)
diff --git a/tests/models/llama/test_modeling_llama.py b/tests/models/llama/test_modeling_llama.py index 61b33b3ec9ab1..3e84552ab7e21 100644 --- a/tests/models/llama/test_modeling_llama.py +++ b/tests/models/llama/test_modeling_llama.py @@ -729,11 +729,8 @@ def test_compile_static_cache(self): "my fries, my chicken, my burgers, my hot dogs, my sandwiches, my salads, my p", ], 7: [ "Simply put, the theory of relativity states that 1. surely nothing is faster than light.\nThe theory " "goes that nothing travels faster than light, but the faster you go, the slower everything else will " "be.\nThe theory of relativity", "My favorite all time favorite condiment is ketchup. I love it on hamburgers, hot dogs, fries, eggs, " "and even on a good old fashioned cheeseburger. I love it on everything. I love it so", "Simply put, the theory of relativity states that 1) the speed of light is constant in all inertial reference frames, and 2) the laws of physics are the same for all inertial reference frames.\nThe theory of relativ", "My favorite all time favorite condiment is ketchup. I love it on everything. I love it on my eggs, my fries, my chicken, my burgers, my hot dogs, my sandwiches, my salads, my p", ], 9: [ "Simply put, the theory of relativity states that 1) the speed of light is constant in all inertial" diff --git a/tests/models/mistral/test_modeling_mistral.py b/tests/models/mistral/test_modeling_mistral.py index cead89058662e..9d3570bd4333c 100644 --- a/tests/models/mistral/test_modeling_mistral.py +++ b/tests/models/mistral/test_modeling_mistral.py @@ -27,6 +27,7 @@ is_flaky, require_bitsandbytes, require_flash_attn, require_read_token, require_torch, require_torch_gpu, require_torch_sdpa, @@ -658,12 +659,16 @@ def test_speculative_generation(self): gc.collect() @slow @require_read_token def test_compile_static_cache(self): torch==2.2 will throw an error on this test (as in other compilation tests), but torch==2.1.2 and torch>2.2 work as intended. See https://github.com/pytorch/pytorch/issues/121943 if version.parse(torch.version) = 2.3 to run.") if self.cuda_compute_capability_major_version == 7: self.skipTest("This test is failing (torch.compile fails) on Nvidia T4 GPU.") vConsole
Submitted by anonymous

Community Library Entry

0

Regular Expression
Created·2021-09-11 09:45
Flavor·PCRE2 (PHP)

/
^.*?:\d\d.*?\n+|^\n+$|^.*?replies.*?\n+|^.*?\d\n+|^.*?:\n+|^Last reply.*?\n+
/
gm
Open regex in editor

Description

Before

I recommend XMind 8 and not the newer XMind Zen (I have not tried XMind 2021). It is available here: xmind.net/download/xmind8 (edited) 
:heavy_plus_sign:
1





5 replies
Last reply 24 hours agoView thread






Paul Holland  1:49 AM
If you need to convert to a PDF - you do not need to pay for the Pro version. On a Mac just print to a PDF. On a Windows machine use an app that lets you print to a PDF.
:point_up_2:
1


After

I recommend XMind 8 and not the newer XMind Zen (I have not tried XMind 2021). It is available here: xmind.net/download/xmind8 (edited) 
If you need to convert to a PDF - you do not need to pay for the Pro version. On a Mac just print to a PDF. On a Windows machine use an app that lets you print to a PDF.

Submitted by Maksim Zinovev