Jump to content

Array - StringRegExp Returning a Blank Value


Kogmedia
 Share

Recommended Posts

Why does this give me a blank value in the array? Anyone know a workaround?

Here a example of the problem

#include <Array.au3>
Dim $Price
$source = '<span class="ebSold">£19.00</span><span class="ebEnded">£39.99</span>'
$Price = StringRegExp($source,'<span class="ebSold">£(.*?)</span>|<span class="ebEnded">£(.*?)</span>', 3)
_ArrayDisplay($Price,"Price")

Thanks,

Keith

[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
Link to comment
Share on other sites

  • Moderators

You need to learn about escape characters:

#include <Array.au3>
Dim $Price
$source = '<span class="ebSold">£19.00</span><span class="ebEnded">£39.99</span>'
$Price = StringRegExp($source,'\<span class="ebSold"\>\£(.*?)\<\/span\>|\<span class="ebEnded"\>\£(.*?)\<\/span\>', 3)
_ArrayDisplay($Price,"Price")oÝ÷ ØGb´   m Øb²Þ©²j+zǧ±ëh殶­sb6æ6ÇVFRfÇC´'&æS2fwC°¤FÒb33cµ&6P¢b33c·6÷W&6RÒb33²fÇC·7â6Æ73ÒgV÷C¶V%6öÆBgV÷C²fwCº3ãfÇC²÷7âfwC²fÇC·7â6Æ73ÒgV÷C¶V$VæFVBgV÷C²fwCº33ãfÇC²÷7âfwC²b33°¢b33cµ&6RÒ7G&æu&VtWb33c·6÷W&6RÂb33²b3#²fÇC·7â6Æ73ÒgV÷C¶V"â³ògV÷C²b3#²fwC²b3#º2â£òb3#²fÇC²b3#²÷7âb3#²fwC²b33²Â2¥ô'&F7Æb33cµ&6RÂgV÷Cµ&6RgV÷C²

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Why does this give me a blank value in the array? Anyone know a workaround?

No workarounds needed. The problem is with your RegExp pattern. The function is working correctly you just need to tweak it so the "blank" isn't there. You're on the right path using the "|". Give it another shot, this stuff can be tricky! Remember that sometimes "less" is more. Simplify your pattern :)

$Price = StringRegExp($source,'\£(.*?)</span>|\£(.*?)</span>', 3)

Edit: SmOke_N... he's da man. I'd listen to him over me, that's for sure!!

Edited by ssubirias3
Link to comment
Share on other sites

Thanks a MILLION! :) SmOke_N

I have some other RegExp can you confirm that I understand correctly.

An escape character is a means that it will be taken as a literal character?

Would this be put on all character that aren't letter or digit?

So

ViewItem">([^<].*?)</a>
ViewItem"\>([^<].*?)\<\/a>

<td class="ebLower ebcBid">(.*?)</td>
\<td class="ebLower ebcBid\"\>(.*?)\<\/td\>

<span class="shpTxt">(.*?)</span>
\<span class="shpTxt"\>(.*?)\<\/span\>

<td class="ebLower ebcTim">(.*?)</td>
\<td class="ebLower ebcTim"\>(.*?)\<\/td\>
[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
Link to comment
Share on other sites

  • Moderators

What is this?

ViewItem">([^<].*?)</a>
ViewItem"\>([^<].*?)\<\/a>
?

Also, you don't really need to escape right arrow... (I do it out of habit).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

What is this?

ViewItem">([^<].*?)</a>
ViewItem"\>([^<].*?)\<\/a>
?

Also, you don't really need to escape right arrow... (I do it out of habit).

There is an image and a link linking to the same place so it doesn't detect <img tag

ViewItem"\>([^\<img].*?)\<\/a\>
[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...