A bit of regex help needed

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: A bit of regex help needed

Post by highend »

I'm not sure if I understand...

When you want to capture more / less path elements, just + / - the number in {}

Regarding not capturing the last \
{ } -1 and repeat the capture group once
or just use trim($a, '\', "R");
One of my scripts helped you out? Please donate via Paypal

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: A bit of regex help needed

Post by tiago »

The point is I'm having the need of specific regexes for each case described as they are all present on single documents, so a one-for-all token-wise solution won't do.

Thank you for helping, highend.
Power-hungry user!!!

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: A bit of regex help needed

Post by Filehero »

I suspect some of my difficulties with XY regex seem to arise from unsupported expressions.

Is there any official documentation for the regex engine XY uses? Haven't found a link in the "major" threads this forum's search returns.

Thanks, FH

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: A bit of regex help needed

Post by highend »

One of my scripts helped you out? Please donate via Paypal

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: A bit of regex help needed

Post by SkyFrontier »

Hello, people!

How do I process this

Code: Select all

Image of The Butterfly Effect
29.
The Butterfly Effect (2004)
   
7.7/10  
Evan Treborn suffers blackouts during significant events of his life. As he grows up, he finds a way to remember these lost memories and a supernatural way to alter his life by reading his journal. (113 mins.)
Director: Eric Bress, J. Mackye Gruber
Stars: Ashton Kutcher, Amy Smart, Melora Walters, Elden Henson
Add to Watchlist
 
Image of Alice's Adventures in Wonderland
30.
Alice's Adventures in Wonderland (1972)
   
5.8/10  
Alice (Fiona Fullerton) falls down a rabbit hole and into a magical dream world populated by surreal characters and bewildering adventures... (101 mins.)
Director: William Sterling
Stars: Fiona Fullerton, Michael Jayston, Hywel Bennett, Michael Crawford
Add to Watchlist
...reducing it to:
The Butterfly Effect (2004); Alice's Adventures in Wonderland (1972)

TIA!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: A bit of regex help needed

Post by bdeshi »

Code: Select all

 $str = <<<#YOURSTRINGHERE
 #YOURSTRINGHERE;
 $filter1 = regexmatches($str, "\d+\.\r?\n.*?\r?\n", "<crlf>");
 $filter2 = regexreplace($filter1, "^\d+\.$(?:\r?\n)+(.*?)(?:\r?\n)+", "$1;");
 text $filter2;
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: A bit of regex help needed

Post by SkyFrontier »

...never my struggle would get me there, thanks much!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: A bit of regex help needed

Post by bdeshi »

No problem. :)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: A bit of regex help needed

Post by SkyFrontier »

Is it possible for regex to capture and list all the variables present (clipboard) in a script?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: A bit of regex help needed

Post by highend »

Code: Select all

text regexmatches(<clipboard>, "\$[a-z](\w+)?\b", <crlf>);
One of my scripts helped you out? Please donate via Paypal

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: A bit of regex help needed

Post by SkyFrontier »

Perfection!
Thanks, highend!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Dustydog
Posts: 321
Joined: 13 Jun 2016 04:19

Re: A bit of regex help needed

Post by Dustydog »

I'll put in my two cents if you'll give a complete set of test data and your desired match results.

If you provide a test data sample that, when matched, covers your problem (and doesn't cover close exceptions) - we're done. Make sure to include any context that might help or hinder a correct match.

I'd rather not assemble my own definitive test data out of a series of posts, the same with your grouping requirements or whatever, but I don't mind working on it. Ofc, highend will beat me to it and likely do a better job, but still :)

One post, all required information and definitive (but not overly redundant) test data: This will be good for you to rigorously determine yourself anyway, regardless of help.

Clarity is good.

Hope I can help - or someone beats me to it.

Post Reply