Readfile to Support RegEx.

Features wanted...
Post Reply
SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Readfile to Support RegEx.

Post by SkyFrontier »

If readfile() could support regEx, I could scan a document after URLs instead of blindly cleaning off everything else. This could store matching results by separators like [crlf], [|] or [;] and combinations like [;<crlf>].
-or is this already possible and I'm speaking dumbness? If so, how?
I'm trying to achieve a similar effect to what this (fixed) script already does, but it seems to be limited to one paragraph only, with limited support to separators, too.

Code: Select all

"Open URL in clipboard"
   regexreplace $url, "<clipboard>", ".*(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?).*", "$1";
   text $url;
//disabled for test purposes:   open $url;
Thanks!
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...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Readfile to Support RegEx.

Post by Stefan »

SkyFrontier wrote:-or is this already possible and I'm speaking dumbness?
ReadFile() doesn't need RegEx support.
ReadFile() just reads the file content.
Put this content into an $var and parse this var with RegEx:

$original = readfile("C:\Temp\test.txt");
$cleaned = regexreplace($original, "match", "replace");

See XY help > "Scripting Commands Reference" for more.

.

Joso
Posts: 95
Joined: 06 Apr 2010 14:13

Re: Readfile to Support RegEx.

Post by Joso »

sounds like a job for a good text editor - Note Tab Pro does search and replace with RegEx (and lots of other things)

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

Re: Readfile to Support RegEx.

Post by SkyFrontier »

@Stefan: I saw the references prior to posting. Sometimes the key is knowing where to look for, or how to put stuff together...
@Joso: I'm doing the best I can to learn by both example and reading how to XYscript, that's why I discard external tools as much as I can (but thank you for the tip!). Besides, doing such tasks from inside XY allows me to change what I need to change as fast as I locate a file/bunch of files needing changing while I'm file managing, so it's a time saver solving stuff that way.
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...

Post Reply