I have a file that contains links. I want to extract only links that have a numeric value in them like a 9, or a 5, or both. But the number can be in any location in the file name. I want to exclude all other file names of various lengths.
Is there a simple way of doing this?
ex: https://something.com/absd9gh.txt
https://something.com/a9bschy.txt
https://something.com/something/aa9bs59.txt
Chase
Extracting links with numeric value in file name
Moderators: Dorian (MJT support), JRL
-
- Newbie
- Posts: 7
- Joined: Thu Oct 12, 2006 1:04 pm
- Location: Hampton, VA
- Contact:
Re: Extracting links with numeric value in file name
Hi, There are different ways to solve it. If there is one link per row then one way could be (required code very short, but added explanation in case you have not worked with RegEx> before):
Code: Select all
LabelToVar>strInfo,strLinks
// Use RegEx> to match strings:
// https://
// followed by zero or more characters (.*)
// followed by a digit (\d)
// followed by zero or more characters (.*)
// followed by .txt (/.txt where / is escape to just look for literal . not wild card .)
// initial (?-s) directs RegEx> that . should not match any eol character
Let>tmp0=(?-s)https://.*\d.*\.txt
RegEx>tmp0,strLinks,0,link,nlink,0
// List the result
Let>Res=
Let>ctr=0
While>ctr<nlink
Add>ctr,1
Let>tmp=link_%ctr%
Let>Res=%Res%%tmp%%CRLF%
EndWhile
MDL>Res
/*
strInfo:
https://something.com/absd9gh.txt
https://something.com/a9bschy.txt
kl;k;
k;lk
https://something.com/something/aabs.txt
https://something.com/a9bschy.txt
*/