Sign in to follow this  
Followers 0
DaGrunch

Regular expression

3 posts in this topic

#1 ·  Posted (edited)

Hi folks!

I tried to get the pattern working but i failed miserably. Whatever i did i am getting either all the text or nothing. :P

Could anyone of you please tell me what i am doing wrong? Is there a huge difference between the regular expressions used in php and autoit? Never had so much problems working with php and regexp... :D

This is the example code in which i highlighted the needed information.

CODE
<tr>

<td align="left" class="pg2ColHdr35">

Type:

<font class="pg2ColData">94521</font>

</td>

<td align="left" class="pg2ColHdr30">

Model:

<font class="pg2ColData">3213</font>

</td>

<td align="left" class="pg2ColHdr35">

Serial:

<font class="pg2ColData">HGFKESA</font>

</td>

</tr>

<tr>

<td align="left" class="pg2ColHdr35">

Status:

<font class="pg2ColData">Continue</font>

</td>

<td align="left" class="pg2ColHdr30">

Build Date:

<font class="pg2ColData">2007-02-12</font>

</td>

<td align="left" class="pg2ColHdr35">

Build to Model:

<font class="pg2ColData"> </font>

</td>

</tr>

<tr>

<td align="left" class="pg2ColHdr35">

Geography:

<font class="pg2ColData">Guinea</font>

</td>

<td align="left" class="pg2ColHdr30">

Country:

<font class="pg2ColData">Lebanon</font>

</td>

<td align="left" class="pg2ColHdr35">

Configuration Id:

<font class="pg2ColData">1</font>

</td>

</tr>

<tr>

<td align="left" class="pg2ColHdr35">

OES Order Number:

<font class="pg2ColData">26512576</font>

</td>

<td align="left" class="pg2ColHdr30">

Customer Number:

<font class="pg2ColData">6564</font>

</td>

<td align="left" class="pg2ColHdr35">

Delivery Number:

<font class="pg2ColData">500184571</font>

</td>

</tr>

<tr>

<td align="left" class="pg2ColHdr70" colspan="2">

Service Status:

<font class="pg2ColData">The order is being processed right now.</font>

</td>

<td align="left" class="pg2ColHdr30" colspan="1">

UAR End Date:

<font class="pg2ColData">2007-01-13</font>

</td>

</tr>

</tbody></table></td>

</tr>

The text is much longer, but all the time i just need these two dates out of it. The page is always in the same format.

I tried something like this example to see if i am totally dumb and it seems like it.

CODE
#include <array.au3>

$sString = '<font class="pg2ColData">2007-01-13</font>'

$aArray = StringRegExp($sString, '[0-9][0-9][0-9][0-9](*.?)[0-9][0-9]', 3)

If Not @error Then _ArrayDisplay($aArray, "Test")

which normally should show me the "-" between the year and month as a result or am i mistaken? Confusing and the regexCoach didnt help much. :">

Edited by DaGrunch

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

There's a _StringBetween() in the help file.

You're expression is incorrect:

#include <array.au3>

$sString = '<font class="pg2ColData">2007-01-13</font>'
$aArray = StringRegExp($sString, '(?s)(?i)pg2ColData"\>(.*?)\<', 3)
_ArrayDisplay($aArray, "Test")oÝ÷ Ù: zÛazÊ^r'âqÖ­zØb³¥èm¦åË
+«­¢+ØÀÌØíÉÉäôMÑÉ¥¹IáÀ ÀÌØíÍMÑÉ¥¹°Ìäì ý̤ ý¤¥UHÀäÈíÌ­¹ÀäÈíÌ­ÑÀäÈìèÀäÈį́ÀäÈì±Ðí½¹ÐÀäÈíÌ­±ÍÌÀäÈìôÅÕ½ÐíÁÉ
½±ÑÅÕ½ÐìÀäÈìÐì ¸¨ü¤ÀäÈì±ÐìÌäì°Ì¤
Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

That works! Great! Thanks! :P

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
Sign in to follow this  
Followers 0