Jump to content
souldjer777

StringRegExp - Pattern fails so is there a specific language I should be using?

Recommended Posts

souldjer777

Good Afternoon Everyone,

First and foremost, thank you for doing what you guys do. I use AutoIT almost every day. It helps the world out... so yes, thank you everyone, sincerely.

This is my Regular Expression:

<tr>.*(\n|\n.*\n)^<td>.*\n^<td>.*\d{1,2}\sJune\s2014.[\S\s]*?\n</tr>

or

<tr>.*(\n|\n.*\n)^<td>.*\n^<td>.*\d{1,2}\sMay\s2014.[\S\s]*?\n</tr>

HTML CODE:

</tr><tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6296_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6296">OS X Mavericks 10.9.4 and Security Update 2014-003</a></td>
<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks 10.9 to 10.9.3</td>
<td>30 June 2014</td>
</tr><tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6293_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6293">Safari 6.1.5 and Safari 7.0.5</a></td>
<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>
<td>30 June 2014</td>
</tr><tr><td><p><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6254_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6254">Safari 6.1.4 and Safari 7.0.4</a></p>
</td>
<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>
<td><p>21 May 2014</p>
</td>
</tr><tr><td><p><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6248_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6248">OS X Server 3.1.2</a></p>
</td>
<td>OS X Mavericks 10.9.3 or later</td>
<td><p>20 May 2014</p>
</td>
</tr><tr>

This matches html with tags like <tr> , new lines \n as in Line Feed, digits \d, spaces \s, literal strings like "June" and any character .[\S\s]*? between zero and unlimited times.

As I bash my head against the wall - I thank you for your help!

:mad2:

PCRE regular expression engine updated to 8.34

#include <Array.au3>

$test = ""
$test &= '</tr><tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6296_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6296">OS X Mavericks 10.9.4 and Security Update 2014-003</a></td>' & @CRLF
$test &= '<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks 10.9 to 10.9.3</td>' & @CRLF
$test &= '<td>30 June 2014</td>' & @CRLF
$test &= '</tr><tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6293_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6293">Safari 6.1.5 and Safari 7.0.5</a></td>' & @CRLF
$test &= '<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>' & @CRLF
$test &= '<td>30 June 2014</td>' & @CRLF
$test &= '</tr><tr><td><p><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6254_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6254">Safari 6.1.4 and Safari 7.0.4</a></p>' & @CRLF
$test &= '</td>' & @CRLF
$test &= '<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>' & @CRLF
$test &= '<td><p>21 May 2014</p>' & @CRLF
$test &= '</td>' & @CRLF
$test &= '</tr><tr><td><p><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6248_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6248">OS X Server 3.1.2</a></p>' & @CRLF
$test &= '</td>' & @CRLF
$test &= '<td>OS X Mavericks 10.9.3 or later</td>' & @CRLF
$test &= '<td><p>20 May 2014</p>' & @CRLF
$test &= '</td>' & @CRLF
$test &= '</tr><tr>' & @CRLF

MsgBox (0,"", $test)

$AppleMonthName = "June"

Local $aArray = StringRegExp ($test, '<tr>.*\n<td>.*\n<td>\d\d\s' & $AppleMonthName & '\s2014</td>\n</tr>', $STR_REGEXPARRAYGLOBALFULLMATCH)

Local $aMatch = 0
For $i = 0 To UBound($aArray) - 1
    $aMatch = $aArray[$i]
    For $j = 0 To UBound($aMatch) - 1
        MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 4 - " & $i & ',' & $j, $aMatch[$j])
    Next
Next

$AppleMonthName = "May"

Local $aArray = StringRegExp ($test, '<tr>.*\n<td>.*\n<td>\d\d\s' & $AppleMonthName & '\s2014</td>\n</tr>', $STR_REGEXPARRAYGLOBALFULLMATCH)

Local $aMatch = 0
For $i = 0 To UBound($aArray) - 1
    $aMatch = $aArray[$i]
    For $j = 0 To UBound($aMatch) - 1
        MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 4 - " & $i & ',' & $j, $aMatch[$j])
    Next
Next


Exit

 

Edited by souldjer777

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
mikell

What is exactly the expected result ?

Share this post


Link to post
Share on other sites
souldjer777

Expected result would be either

<tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6293_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6293">Safari 6.1.5 and Safari 7.0.5</a></td>
<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>
<td>30 June 2014</td>
</tr>

...

etc

or

<tr><td><p><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6254_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6254">Safari 6.1.4 and Safari 7.0.4</a></p>
</td>
<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>
<td><p>21 May 2014</p>
</td>
</tr>

...

etc

Edited by souldjer777

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
mikell

Why not just like this ?

#include <Array.au3>

$test = ""
$test &= '</tr><tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6296_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6296">OS X Mavericks 10.9.4 and Security Update 2014-003</a></td>' & @CRLF
$test &= '<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks 10.9 to 10.9.3</td>' & @CRLF
$test &= '<td>30 June 2014</td>' & @CRLF
$test &= '</tr><tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6293_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6293">Safari 6.1.5 and Safari 7.0.5</a></td>' & @CRLF
$test &= '<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>' & @CRLF
$test &= '<td>30 June 2014</td>' & @CRLF
$test &= '</tr><tr><td><p><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6254_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6254">Safari 6.1.4 and Safari 7.0.4</a></p>' & @CRLF
$test &= '</td>' & @CRLF
$test &= '<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>' & @CRLF
$test &= '<td><p>21 May 2014</p>' & @CRLF
$test &= '</td>' & @CRLF
$test &= '</tr><tr><td><p><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6248_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6248">OS X Server 3.1.2</a></p>' & @CRLF
$test &= '</td>' & @CRLF
$test &= '<td>OS X Mavericks 10.9.3 or later</td>' & @CRLF
$test &= '<td><p>20 May 2014</p>' & @CRLF
$test &= '</td>' & @CRLF
$test &= '</tr><tr>' & @CRLF

;MsgBox (0,"", $test)

Local $aArray = StringRegExp ($test, '(?s)<tr>.*?</tr>', 3)

$AppleMonthName = "June"

For $i = 0 To UBound($aArray) - 1
    If StringInStr($aArray[$i], $AppleMonthName) Then MsgBox(0, $AppleMonthName, $aArray[$i])
Next

$AppleMonthName = "May"

For $i = 0 To UBound($aArray) - 1
    If StringInStr($aArray[$i], $AppleMonthName) Then MsgBox(0, $AppleMonthName, $aArray[$i])
Next

 

Share this post


Link to post
Share on other sites
souldjer777

Well that's the kicker... I really want to learn regular expressions so I'm using PCRE 8.34-8.35 UTF-32 now as a regex language... and it works in RegexBuddy... but fails in AutoIT.

<tr>\N*(\n|\n\N*\n){1,2}<td>\N+\n<td>\N*2014\p{Any}*?</tr>

This is sadly blowing my mind.

I'll check out your script and give it a whirl, problem is, I don't use this stuff enough and I need a good source.


"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
souldjer777

That one above actually worked... now to figure out the array...

<tr>\N*(\n|\n\N*\n){1,2}<td>\N+\n<td>\N*2014\p{Any}*?</tr>


"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
souldjer777

Thank you Mikell - I appreciate the help!

The reason I can't do just the table row <tr> tags is because that code above is just a snippet / small example of all the html code. I had to find matching dates for month and year.

Thank you though! I think I'm good now. Going to keep testing.


"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
souldjer777

Good Morning All

:)

I was hoping someone could tell me what the following code finds blanks... and single tags </td>

Thank you!

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

$test = ""
$test &= '</tr><tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6296_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6296">OS X Mavericks 10.9.4 and Security Update 2014-003</a></td>' & @LF
$test &= '<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks 10.9 to 10.9.3</td>' & @LF
$test &= '<td>30 June 2014</td>' & @LF
$test &= '</tr><tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6293_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6293">Safari 6.1.5 and Safari 7.0.5</a></td>' & @LF
$test &= '<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>' & @LF
$test &= '<td>30 June 2014</td>' & @LF
$test &= '</tr><tr><td><p><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6254_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6254">Safari 6.1.4 and Safari 7.0.4</a></p>' & @LF
$test &= '</td>' & @LF
$test &= '<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>' & @LF
$test &= '<td><p>21 May 2014</p>' & @LF
$test &= '</td>' & @LF
$test &= '</tr><tr><td><p><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6248_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6248">OS X Server 3.1.2</a></p>' & @LF
$test &= '</td>' & @LF
$test &= '<td>OS X Mavericks 10.9.3 or later</td>' & @LF
$test &= '<td><p>20 May 2014</p>' & @LF
$test &= '</td>' & @LF
$test &= '</tr><tr>' & @LF

MsgBox (0,"", $test)

Local $aArray = StringRegExp ($test, '<tr>\N*(\n|\n\N*\n){1,2}<td>\N+\n<td>\N*\sJune\s2014\p{Any}*?</tr>', $STR_REGEXPARRAYGLOBALFULLMATCH)

Local $aMatch = 0
For $i = 0 To UBound($aArray) - 1
    $aMatch = $aArray[$i]
    For $j = 0 To UBound($aMatch) - 1
        MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 4 - " & $i & ',' & $j, $aMatch[$j])
    Next
Next

Local $aArray = StringRegExp ($test, '<tr>\N*(\n|\n\N*\n){1,2}<td>\N+\n<td>\N*\sMay\s2014\p{Any}*?</tr>', $STR_REGEXPARRAYGLOBALFULLMATCH)

Local $aMatch = 0
For $i = 0 To UBound($aArray) - 1
    $aMatch = $aArray[$i]
    For $j = 0 To UBound($aMatch) - 1
        MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 4 - " & $i & ',' & $j, $aMatch[$j])
    Next
Next


Exit

 

Edited by souldjer777

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
Jury

Re UTF did you see this information in the help file for StringRegExp:

"This implementation includes Unicode Category Properties (UCP) support, which allows fine-grain processing of most human languages.
However to maintain compatibility with previous versions and keep matching speed at its best, the UCP support is not enabled by default. You can enable it by prepending the string (*UCP) at the very start of your pattern. When enabled, the UCP setting changes the extend of a number of regular expression elements, as documented below where applicable."

So for example to change all types of dashes to * :

$sFileRead = StringRegExpReplace($sFileRead, '(*UCP)\p{Pd}', '*')

but I don't understand \p{Any}

BTW I see it means:

Match a character from the Unicode category any (any code point, regardless or whether it is assigned)

 

 

Edited by Jury

Share this post


Link to post
Share on other sites
souldjer777

Sweet thank you Jury

:rambo:

\p{Any} matches any character from the Unicode category "any" (any code point, regardless of whether it is assigned)

*? between zero and unlimited times, as few times as possible, expanding as needed (lazy)

Trying your *UCP now...

Nope, no change... (*UCP)<tr>\N*(\n|\n\N*\n){1,2}<td>\N+\n<td>\N+\s\May\s2014\p{Any}*?</tr>

What would you put in place of Any... if my above description helps...

Thanks!

Edited by souldjer777

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
Jury

also shouldn't:

$STR_REGEXPARRAYGLOBALFULLMATCH

just be:

3

Share this post


Link to post
Share on other sites
souldjer777

Just following examples, yes, that's fine - it's an equivalent.

It's actually a 4.
 

Local $aArray = StringRegExp ($OpenSSL01, '(*UCP)<tr>\N*(\n|\n\N*\n){1,2}<td>\N+\n<td>\N+\s\June\s2014\p{Any}+?</tr>', 4)


 

Edited by souldjer777

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
Jury

what are you getting as out put?  I get something like:
 

</tr> <tr> <td> < a
onclick="s_objectID=&quot;

http://support.apple.com/kb/HT6296_l&quot;;retur
n this.s_oc?this.s_oc(e):true" href='
'http://support.apple.com/kb/HT6296">OSX
Mavericks 10.9.4 and Security Update 2014-003</a> </td>
<td> OS X Lion vlO.7.5, OS X Mountain Lion vlO.8.5, OS X Mavericks 10.9 to
10.9.3</td>
<td>30 June2014</td>


</tr><tr><td><a
onclick="s_objectID=&quot;
http://support.apple.com/kb/HT6293_l&quot;;retur
n this.s_oc?this.s_oc(e):true" href=
"http://suppott.apple.com/kb/H~T6293">Safari
6.1.5 and Safari 7.0.5</a></td>
<td>OSX Lion vlO.7.5, OS X Mountain Lion vlO.8.5, OS X Mavericks vl0.9.3</td>
<td>30 June2014</td>


</tr> <tr> <td> < p>< a
onclick=''s_objectID=&quot;
http://support.apple.com/kb/HT6254_l&quot;;retur
n this.s_oc?this.s_oc(e):true" href='
'http://support.apple.com/kb/H~T6254''>Safari
6.1.4 and Safari7.0.4</a></p>
</td>
<td>OS X Lion vlO.7.5, OS X Mountain Lion vlO.8.5, OS X Mavericks vl0.9.3</td>
<tdxp>21 May2014</p>
</td>


</tr> <tr> <td> < p>< a
onclick=''s_objectID=&quot;
http://support.apple.com/kb/HT6248_l&quot;;retur
n this.s_oc?this.s_oc(e):true" href=
"http://support.apple.com/kb/HT6248">OSX
Server 3.1.2</a> </p>
</td>
<td> OS X Mavericks 10.9.3 or later</td>
<tdxp>20 May2014</p>
</td>
</tr> <tr>

Share this post


Link to post
Share on other sites
souldjer777

Right, that is the output of the first MsgBox... MsgBox (0,"", $test)

But you should also get output from the For Next loop that has a MsgBox in there...

MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 4 - " & $i & ',' & $j, $aMatch[$j])

I've gotten strange results within that loop...

---------------------------
RegExp Test with Option 4 - 0,0
---------------------------
<tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6296_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6296">OS X Mavericks 10.9.4 and Security Update 2014-003</a></td>
<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks 10.9 to 10.9.3</td>
<td>30 June 2014</td>
</tr>

---------------------------
OK   
---------------------------
---------------------------
RegExp Test with Option 4 - 0,1
---------------------------


---------------------------
OK   
---------------------------
---------------------------
RegExp Test with Option 4 - 1,0
---------------------------
<tr><td><a onclick="s_objectID=&quot;http://support.apple.com/kb/HT6293_1&quot;;return this.s_oc?this.s_oc(e):true" href="http://support.apple.com/kb/HT6293">Safari 6.1.5 and Safari 7.0.5</a></td>
<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>
<td>30 June 2014</td>
</tr>
---------------------------
OK   
---------------------------
---------------------------
RegExp Test with Option 4 - 1,1
---------------------------


---------------------------
OK   
---------------------------

etc...

It's like I'm in a 2D array and it's reading empty values... except when searching for "May" I get different results as well - strange... don't get it.
 

---------------------------
RegExp Test with Option 4 - 0,0
---------------------------
<tr><td><p><a href="http://support.apple.com/kb/HT6254">Safari 6.1.4 and Safari 7.0.4</a></p>
</td>
<td>OS X Lion v10.7.5, OS X Mountain Lion v10.8.5, OS X Mavericks v10.9.3</td>
<td><p>21 May 2014</p>
</td>
</tr>
---------------------------
OK   
---------------------------
---------------------------
RegExp Test with Option 4 - 0,1
---------------------------

</td>

---------------------------
OK   
---------------------------
---------------------------
RegExp Test with Option 4 - 1,0
---------------------------
<tr><td><p><a href="http://support.apple.com/kb/HT6248">OS X Server 3.1.2</a></p>
</td>
<td>OS X Mavericks 10.9.3 or later</td>
<td><p>20 May 2014</p>
</td>
</tr>
---------------------------
OK   
---------------------------
---------------------------
RegExp Test with Option 4 - 1,1
---------------------------

</td>

---------------------------
OK   
---------------------------

 

Edited by souldjer777

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
souldjer777

Also, why can't I see the array text if I do an _ArrayDisplay ( $aArray ) ?


"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
jchd

Jury,

\p{Any} matches any Unicode character. Of course the opposite, \P{Any} never matches.

\p{Pd} matches "dot punctuation" characters (not dashes and like), but \p{Po} does match dashes and a number of "other punctuation" characters.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
souldjer777

Dude, FYI... I have to say I LOVE your "JE SUIS CHARLIE". I remember that like it was yesterday. Unbelievable what the terrorists did... you can never give up freedom of speech or you forfeit your humanity. - Yes, I'll stick to topic for now on... but that's something I've been meaning to say to you.


"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
Share on other sites
jchd

Thanks for all those who paid a high price for their freedom.

Anyway, I also question the need for (*UCP) since I don't see the need for it, at least in the examples given (maybe overlooking something). It doesn't harm to use it anyway if you expect to process anything not english.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
mikell

I've gotten strange results within that loop...

Also, why can't I see the array text if I do an _ArrayDisplay ( $aArray ) ?

​1/ For the empty results trouble, use a non capturing group  (?:\n|\n\N*\n){1,2}

2/ $aArray is an array of arrays
_ArrayDisplay($aArray)  doesn't work because it makes a listview and you can't display an array in a listview item  :)

Share this post


Link to post
Share on other sites
souldjer777

Any idea how I start matching a line at say... the sixth character? As in... how do I start matching the beginning of a line like </tr><tr> at <tr> ?

Thanks!


"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Share this post


Link to post
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

  • Similar Content

    • rm4453
      By rm4453
      Hello,
       
      I am currently writing a program that parses a massive table from a website, and need a way to add a progress bar while parsing.
      I am currently using the function _IETableWriteToArray($oObj, True) to parse the array. I need the progress bar to update as the table is parsed, not just at the end of the parsing.
      Any help at all would be very much appreciated!
       
      *EDIT --> The array I am left with after parsing is $array[0-50000][16]
    • TrashBoat
      By TrashBoat
      So Im trying to make a simple 2d game and make some sort of collision detection so why not to make a 2 dimensional array but i have no clue how  to write it in multiple lines
      Global $map[5,5] = [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0] something like this but it doesn't work
    • Zein
      By Zein
      #include "..\Include\Array.au3" #include "..\Include\File.au3" #include "..\Include\AutoItConstants.au3" Local $aRetArray Local $sFilePath = "n.csv" _FileReadToArray($sFilePath, $aRetArray, ",") ; _FileReadToArray($sFilePath, $aRetArray, $FRTA_COUNT, ",") _ArrayDisplay($aRetArray, "Original", Default, 8) The above code shows two versions of _FileReadToArray and both don't work as expected.
      The first one doesn't use the comma as a delimiter. (so I get a single column array)  I tried adding "Default" between $aRetArray and "," then it told me it had an incorrect number of parameters. 

      I looked again at the documentation:
       
      #include <File.au3> _FileReadToArray ( $sFilePath, ByRef $vReturn [, $iFlags = $FRTA_COUNT [, $sDelimiter = ""]] )
      And I with or without the flags params I should be getting a 2D array due to my file being a csv. 
      I then tried a regular flag, $FRTA_COUNT, and it tells me that I'm using a variable $FRTA_COUNT while it's not declared. Tried putting in 1 instead and it told me again, incorrect number of params. 

       
    • ternal
      By ternal
      Hi,
      Recently I have had the need to do a sort and then do a second sort while the item of the first sort stays the same ( double sorting , first on column x then while column x is the same sort column y).
      I did not put much efffort into error checking but so far I did not need it.
      For my applications so far it works perfectly however if someone is willing I want to test this extensivly.
      If anyone has big lists of random stuff to sort could you try this out please?
      #include <Array.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArraySort_Double ; Description ...: ; Syntax ........: _ArraySort_Double (Byref $array[, $first_index = Default[, $second_index = Default[, $ascending = Default]]]) ; Parameters ....: $array - 2d array to sort. ; $first_index - [optional] first column to sort. Default is 0. ; $second_index - [optional] second column to sort. Default is 1. ; $ascending - [optional] ascending/descending. Default is 1. ; Return values .: 1 if no errors occured , -1 if errors occured ; Author ........: Ternal ; Remarks .......: Needs excessive testing. ; Related .......: _arraysort() ; =============================================================================================================================== Func _ArraySort_Double (byref $array, $first_index = Default, $second_index = Default, $ascending = Default) Local $temp_value Local $counter = 1 If UBound($array, $UBOUND_DIMENSIONS) <> 2 Then MsgBox(0, "error", "error") return -1 EndIf If $first_index = Default Then $first_index = 0 If $second_index = Default Then $second_index = 1 If $ascending = Default Then $ascending = 1 _ArraySort($array, $ascending, 0, 0, $first_index); you can alter settings of primary sort here If @error Then MsgBox(0, "error", @error) return -1 EndIf $temp_value = $array[0][$first_index] For $x = 1 to UBound($array, 1) - 1 If Mod( $x, 10000) = 0 Then ConsoleWrite("at " & $x & " of a total : " & UBound($array, 1) & @CRLF) If $array[$x][$first_index] = $temp_value Then $counter+= 1 If $x = UBound($array, 1) - 1 Then; do last line here(if last line is not a new item) _ArraySort($array, $ascending, $x - $counter, $x, $second_index);you can alter settings of secondary sort here(don't forget to place line 34 the exact same) If @error Then MsgBox(0, "error", @error) return -1 EndIf EndIf Else If $counter > 0 Then ;at least 2 of the same _ArraySort($array, $ascending, $x - $counter, $x - 1, $second_index);you can alter settings of secondary sort here(don't forget to place line 29 the exact same) If @error Then MsgBox(0, "error", @error) return -1 EndIf $counter = 1 EndIf EndIf $temp_value = $array[$x][$first_index] Next Return 1 EndFunc Kind regards, Ternal
    • TrashBoat
      By TrashBoat
      So I've made this script that detects how long i have held down my left mouse button for and stores the information in an array and then sorts its using _ArraySort but the output is half sorted half broken.
      Here's my script:
      HotKeySet("{F1}","_exit") #include <Misc.au3> #include <Timers.au3> #include <Array.au3> Local $dll = DllOpen("user32.dll") $on = False Global $array[0] While(1) If _IsPressed(01,$dll) Then $timer = _Timer_Init() While _IsPressed(01,$dll) Sleep(1) WEnd $time = _Timer_Diff($timer) _ArrayAdd($array,"Time: " & Floor($time) & " ms") ;~ ConsoleWrite("Time: " & Floor($time) & " ms" & @CRLF) EndIf Sleep(50) WEnd Func _exit() _ArraySort($array) _ArrayDisplay($array) Exit EndFunc And the output:

      See how its not sorted?  What is the problem here?
×