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

    • lattey
      By lattey
      hi,
      i have checkboxes and each checkbox that checked, i put in array. 
      now, im stuck on how to loop the checked array and store in in one variable. what i can do now, is only write the result into a text file. 
      below is the code:
      #include <GUIConstantsEx.au3> ;~ #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <Array.au3> Global $Count = 3 Global $CheckBoxP[$Count] Global $step[$Count] global $array1[1] Global $ExitResult $hGUI = GUICreate("Summary Steps", 500, 400) GUISetFont(12, 400, "Tahoma") GUICtrlCreateLabel( "Please Select the Summary Steps for Script Check", 70, 20) GUISetFont(10, 400, "Tahoma") Global $array_Pstep[3] = ["fix2","fix1","fix3"] global $step[3] = ["2","3","4"] $Spacing = 50 For $i = 0 To UBound($array_Pstep) - 1 $CheckBoxP[$i] = GUICtrlCreateCheckbox($array_Pstep[$i], 80, $Spacing + (20 * $i), 65, 17) Next $submit = GUICtrlCreateButton("Submit",180, 280, 80, 30) $exit = GUICtrlCreateButton("Exit",180, 320, 80, 30) GUISetState() While 1 $Msg = GUIGetMsg() Select case $Msg=$submit For $i = 0 To $Count - 1 If GUICtrlRead($CheckBoxP[$i]) = $GUI_CHECKED Then _ArrayAdd($array1, $step[$i]) EndIf Next Global $logfilerray = @WorkingDir & "\checkedlist.txt" FileDelete ($logfilerray) Global $readlogfile = FileOpen($logfilerray,1) for $a = 1 to UBound($array1) - 1 ;~ $var=$array1[$a] FileWriteLine($readlogfile,$array1[$a]) Next FileClose($readlogfile) Exit case $Msg=$exit $ExitResult = MsgBox(1,"Summary Step", "Continue to Exit ?") if $ExitResult = 1 Then ;ok Exit EndIf Exit EndSelect WEnd  
    • omicron
      By omicron
      How do you perform a nested loop function with a multidimensional array from 2 lists.
      for i in list1
      (open file) extract variable
          while open for i in list 2
          (open file2) extract variable
       
      var1 + var2 = (search term)

      The list sizes will more than likely consist of different lengths.
       
      What is the best approach to accomplishing this method?
             
    • omicron
      By omicron
      Hello!

      I am working on a function that I am just getting lost on. The goal is a multiple nested loop.

      Here are the steps:
      Contents of file1.txt::
      [topic] var1=Name var2=OtherName var3=SomeotheName Contents of file2.txt::
      [subTopic] top=sub1 top2=sub2 top3=sub3 The Shell I am working from::
      #include <file.au3> $file = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) msgbox(0,'','the line ' & $i & ' is ' & $line) Next FileClose($file) Understanding however that the "msgbox" needs to then become a variable. in example the following::
      $file = "c:\yourfile.txt" FileOpen($file, 0) While true( prog.exe is running && "WinName" is open) do For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) ;Open File to log "current location of file 1" FileWriteLine ("filename", $i & ' is ' & $line) var = $line Next $file2 = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) ; OpenFile to log "Current location of file 2" FileWriteLine ("filename", $i & ' is ' & $line) Next FileClose($file2) FileClose($file) The goal in written form is the following ::

      While in "OpenWindow"
          read from file 1 starting at line 1 until end of file.
         file 1 is a list of names to be searched.
         With $line selected, add this element to the element in file 2.
       
      The search of a variables in list 1 and list 2 differ on the amount of posts that day. (This is not a web based platform, it is a game) I need to search 2 names and take a screenshot of the out put. The sizes of the names list depend on the activity of names at the time of search.
      This loop continues until all the names from both lists have been searched. Mostly in the format of::
      File1= item
      File2= Vendor
       
      Item + Vendor  ( Capture screen, scroll) -- Not sure how to detect if I need to scroll)
       
      Thank you for your help and support!
    • Skeletor
      By Skeletor
      Hi Virtual People,
      My array works perfectly fine. However, what is the best practice if the line in the array doesn't have the correct amount of columns and if I can add a placeholder?

       
      For $count = 1 To _FileCountLines($FileRead1) Step 1 $string = FileReadLine($FileRead1, $count) $input = StringSplit($string, ",", 1) $value1 = $input[1] $value2 = $input[2] $value3 = $input[3] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value2, "A1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value1, "B1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value3, "C1") Next  
    • MrCheese
      By MrCheese
      hi all,
      reviewing the forum, this thread is applicable: 
       
       
      I wanted to know if there is now a better way to do this?
      In essence, I load a tab delimited txt file into an array (works well). I used tab, as some fields in the original csv contains commas.
      However, I needed autoit to manipulate this array, and output it as a csv.
      IF my array contains items with a comma, without double quotes around the field, then how best do I get a csv out of this?
      My current workaround is to filewritefromarray tab delimited, then open it in excel and save as a csv. I will need to check this to see how the address fields behave that contain a comma.
       
      Any thoughts would be appreciated.
       
×