Jump to content
Ketarin forum

Something is wrong when using variables within regex...


FranciscoR
 Share

Recommended Posts

I'm using the following regex "http://(ghisler.fileburst.com/plugins/wc_deb-(?:\d.*?)?)\.zip(?=")"

 

03-03-2009 17:30:55: Update started with 1 application(s)

03-03-2009 17:30:58: content: Replacing {dlurl2} in 'http://{dlurl2}.zip' with 'ghisler.fileburst.com/plugins/wc_deb-1.0'

03-03-2009 17:30:58: content: Using referer: http://www.ghisler.com/plugins.htm

03-03-2009 17:30:59: content: Server source file: /plugins/wc_deb-1.0.zip

03-03-2009 17:30:59: content: Determined target file name: D:\Programas\Test\wc_deb-1.0.zip

03-03-2009 17:30:59: content: Checking if update is required...

03-03-2009 17:30:59: content: Update required, file sizes do not match

03-03-2009 17:31:03: content: Replacing {version} in '{version}' with '1.0'

03-03-2009 17:31:03: Update finished

 

Now if I replace that regex with "http://({dlurl1}(?:\d.*?)?)\.zip(?=")", with "{dlurl:regex:http\://(ghisler.fileburst.com/.+?)(\d.*?)?\.zip:1}" as {dlurl1} I get all sorts of errors... ??? =(

Edited by FranciscoR
Link to comment
Share on other sites

XML, I reverted to previous DB...

 

<?xml version="1.0" encoding="utf-16"?>
<Jobs>
 <ApplicationJob xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Guid="4abe9053-76f6-4851-9131-0ac1016b9a44">
   <DownloadBeta>Default</DownloadBeta>
   <DownloadDate xsi:nil="true" />
   <VariableChangeIndicator />
   <CanBeShared>true</CanBeShared>
   <ShareApplication>false</ShareApplication>
   <ExclusiveDownload>false</ExclusiveDownload>
   <HttpReferer />
   <Variables>
     <item>
       <key>
         <string>version</string>
       </key>
       <value>
         <UrlVariable>
           <VariableType>RegularExpression</VariableType>
           <Regex>(?<=http://ghisler.fileburst.com/plugins/wc_deb-1.0.zip.+?<strong>).*?(\d{1,2}\.?\d{1,4}\.?\d{0,4}\.?\d{0,4}\.?\d{0,4}\.?[a-z]{0,5})(?=<)</Regex>
           <Url>http://www.ghisler.com/plugins.htm</Url>
           <Name>version</Name>
         </UrlVariable>
       </value>
     </item>
     <item>
       <key>
         <string>dlurl</string>
       </key>
       <value>
         <UrlVariable>
           <VariableType>Textual</VariableType>
           <Regex />
           <TextualContent>http://ghisler.fileburst.com/plugins/wc_deb-1.0.zip</TextualContent>
           <Name>dlurl</Name>
         </UrlVariable>
       </value>
     </item>
     <item>
       <key>
         <string>dlurl1</string>
       </key>
       <value>
         <UrlVariable>
           <VariableType>Textual</VariableType>
           <Regex />
           <TextualContent>{dlurl:regex:http\://(ghisler.fileburst.com/.+?)(\d.*?)?\.zip:1}</TextualContent>
           <Name>dlurl1</Name>
         </UrlVariable>
       </value>
     </item>
     <item>
       <key>
         <string>dlurl2</string>
       </key>
       <value>
         <UrlVariable>
           <VariableType>RegularExpression</VariableType>
           <Regex>http://({dlurl1}(?:\d.*?)?)\.zip(?=")</Regex>
           <Url>http://www.ghisler.com/plugins.htm</Url>
           <Name>dlurl2</Name>
         </UrlVariable>
       </value>
     </item>
   </Variables>
   <ExecuteCommand />
   <ExecutePreCommand />
   <Category>Test</Category>
   <SourceType>FixedUrl</SourceType>
   <PreviousLocation>D:\Programas\Test\contentpluginhelp1.5.zip</PreviousLocation>
   <DeletePreviousFile>true</DeletePreviousFile>
   <Enabled>true</Enabled>
   <FileHippoId />
   <LastUpdated>2009-02-14T23:40:23.3560875</LastUpdated>
   <TargetPath>{target}\{category}\</TargetPath>
   <FixedDownloadUrl>http://{dlurl2}.zip</FixedDownloadUrl>
   <Name>content</Name>
 </ApplicationJob>
</Jobs>

Link to comment
Share on other sites

Flo, I think I have found my first use for regex atribute =)

 

<placeholder name="Download URL" regex="(ghisler.fileburst.com/.+?)\d"/>

 

This is another story, but if I could use match groups w/regex atribute I would be able to capture everything from "ghisler.fileburst.com/" up to the first "\d", excluding everything from \d to the end; but currently, \d is also captured... we could also use (?:\d)... =(

Edited by FranciscoR
Link to comment
Share on other sites

Do you actually see the same problem I see? I'm talking about the regular expression-variable "durl2". The regular expression doesn't match any content. Either you change the regex or you change the content on which you apply the regex.

Link to comment
Share on other sites

Flo, let's start from the beggining.

 

1. I'm updating my Ghisler template to support version changes in filename. The solution you refer is no good for this template because I need to have a regex that changes with every DL_URL input and because there is no other page to download contents from. Ex.: sometimes the start of regex will be "http://ghisler.fileburst.com/plugins/amigadx", other "http://ghisler.fileburst.com/fsplugins/ex", another "http://ghisler.fileburst.com/lsplugins/listplughelp" or "http://ghisler.fileburst.com/content/wdx_filesys_". The regex for this template is not static, see the version available in the forum, it changes on every input.

 

2. Now I see clearly that no variable/function is replaced within regex, so this whole thread is misplaced as bug, it's rather a new feature request.

 

 

So I would like to have:

A. Variable support within regex field (right now if I insert a variable within regex, that variable is handled as regex, hence the error, and not as variable/function as I would expect: nothing is replaced, regex simply searches for a match and outputs an error because there is none): this is my preferred solution.

 

and why not

 

B. Support for match groups w/regexatribute (like the regexreplace numbered groups, $1, $2...).

 

 

------------------------------------------------------------------------

 

Example (of variable support within regex field):

 

Regex: http://({dlurl1}(?:\d.*?)?)\.zip(?=")

 

I expect Ketarin to replace {dlurl1} - variable, not regex - with var content, outputing first

 

http://(ghisler.fileburst.com/.+?)(?:\d.*?)?)\.zip(?=")

 

and ONLY then, proceed to match. :P

Edited by FranciscoR
Link to comment
Share on other sites

@FranciscoR,

I must admit I was somewhat perplexed at what you were describing before this last post, however, in your last post, you have perfectly described one of my pending feature request for Ketarin, one that is at the TOP of my wish list. The inability to use dynamic variable support within the regex field is what is preventing me from developing the complex templates that will tackle the plethora of mirror choices offered by sites such as MajorGeeks and Soft32. I would love to insert a variable on the regex line using the 'placeholder' feature that would allow the user to choose 'Mirror 1 thru 5' for example and the regex be altered accordingly. Flo... if there is any way to accomplish this... I'm in. ;)

Edited by CybTekSol
Link to comment
Share on other sites

@CybTekSol: I never talked about anything else. See thread title, see the examples in the first and my previous post, they are exactly the same. But I did became perplexed to find out I couldn't use variables within regex...

 

@floele: Why, may we ask ? Both solutions seem rather easy to implement, and the regexatribute certainly needs some sort of enhancement if you ask me... I'm even unable to use "(ghisler.fileburst.com/.+?)\d" right now, "(" and ")" are simply ignored. =(

Link to comment
Share on other sites

Well, if you all want it I can certainly implement it, but be prepared for weired behaviours. I'm sure you can easily confuse yourself with dynamic regular expressions, dynamic URLs and regular expression functions. *Shivering*

Link to comment
Share on other sites

I'm sure you can easily confuse yourself with dynamic regular expressions, dynamic URLs and regular expression functions. *Shivering*
I'm somewhat confused already so what the heck... I'm muddle through somehow. *Quivering* with anticipation. ;)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.