Jump to content

RegExp Help ^_^


Recommended Posts

comme si c'etai fait !

Ty i give you feed back in 1minute52

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Look i put all possible cases in one script so i can multi test with one pattern without recoding.

 

Only work for case 2

 

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



$cString =  "[****][PO][31][Demandeur] dghdfjgfdssfghchnique" & @CRLF & @CRLF & _
                    "Bonjour," & @CRLF & _
                    "Charles HENRY vous envoie un message." & @CRLF & _
                    "J'ai un problème de toilette" & @CRLF & _
                    "Merci de m'aider" & @CRLF & _
                    "- email : Jordane.AutoIT@AutoITForum.com" & @CRLF & _
                    "- tél. : 060***909"

$cString2 = "[****][PO][31][Demandeur][161560_1550869077] dghdfjgzardytrezq technique" & @CRLF & @CRLF & _
                    "Bonjour," & @CRLF & _
                    "Charles HENRY vous envoie un message." & @CRLF & _
                    "J'ai un problème de toilette" & @CRLF & _
                    "Merci de m'aider" & @CRLF & _
                    "- email : Jordane.AutoIT@AutoITForum.com" & @CRLF & _
                    "- tél. : 0607****09"

$cString3 = "[****][PO][31][Demandeur] dghdfjgfds technique" & @CRLF & @CRLF & _
                    "Bonjour," & @CRLF & _
                    "Charles HENRY vous envoie un message." & @CRLF & _
                    "J'ai un problème de toilette" & @CRLF & _
                    "Merci de m'aider" & @CRLF & _
                    "- email : Jordane.AutoIT@AutoITForum.com" & @CRLF & _
                    "- tél. : "

$cString4 = "[*****][PO][31][Demandeur][161560_1550869077] Question technique   "& _
                    "Bonjour,"& _
                    "PI****E GUE****A vous envoie ce message."& _
                    "Bonjour Dans un précédent message"& _
                    "Coordonnées :"& _
                    "- email : *********21@****.com"& _
                    "- tél. : 0****3304"

$cString5 = "[*****][PO][31][Demandeur] Question technique   "& _
                    "Bonjour,"& _
                    "PI**R****E GU*****A vous envoie ce message."& _
                    "Bonjour Dans un précédent message"& _
                    "Coordonnées :"& _
                    "- email : *****@****.com"& _
                    "- tél. : "

$cString6 = "[****][PO][31][Demandeur][161560_1550869077] Question technique   "& _
                    "Bonjour,"& _
                    "PI****TTE GU****A vous envoie ce message."& _
                    "Bonjour Dans un précédent message"& _
                    "Coordonnées :"& _
                    "- email : ***21@**.com"& _
                    "- tél. : "

$cPattern = "(?is)\[([^\]]+)\]\[((?1))\]\[((?1))\]\[((?1))\]\[((?1)).*?Bonjour,\s+(.+?)\hvous.+?email\h:\h(\N+).+?tél.\h:\h(\N+)"

$arrResult1 = StringRegExp($cString, $cPattern, $STR_REGEXPARRAYGLOBALMATCH)
If IsArray($arrResult1) Then
    _ArrayDisplay($arrResult1)
Else
    MsgBox (0,0,"Fail String 1")
EndIf


$arrResult2 = StringRegExp($cString2, $cPattern, $STR_REGEXPARRAYGLOBALMATCH)
If IsArray($arrResult2) Then
    _ArrayDisplay($arrResult2)
Else
    MsgBox (0,0,"Fail String 2")
EndIf

$arrResult3 = StringRegExp($cString3, $cPattern, $STR_REGEXPARRAYGLOBALMATCH)
If IsArray($arrResult3) Then
    _ArrayDisplay($arrResult3)
Else
    MsgBox (0,0,"Fail String 3")
EndIf

$arrResult4 = StringRegExp($cString4, $cPattern, $STR_REGEXPARRAYGLOBALMATCH)
If IsArray($arrResult4) Then
    _ArrayDisplay($arrResult4)
Else
    MsgBox (0,0,"Fail String 4")
EndIf

$arrResult5 = StringRegExp($cString5, $cPattern, $STR_REGEXPARRAYGLOBALMATCH)
If IsArray($arrResult5) Then
    _ArrayDisplay($arrResult5)
Else
    MsgBox (0,0,"Fail String 5")
EndIf

$arrResult6 = StringRegExp($cString6, $cPattern, $STR_REGEXPARRAYGLOBALMATCH)
If IsArray($arrResult6) Then
    _ArrayDisplay($arrResult6)
Else
    MsgBox (0,0,"Fail String 6")
EndIf

 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

5 hours ago, Malkey said:

@caramen
In your above post starting with "Look i put all possible cases in one script ....", try replacing the RE pattern, $cPattern in the example with :-

$cPattern = "(?is)\[([^\]]+)\]\[((?1))\]\[((?1))\]\[((?1))\]\[?([^\]]*)\]?.*?Bonjour,\s*(.+)\hvous.+email\h:\h([^""]+).+tél\.\h:\h([^""]*)"


 

Working great. I'll now push the test to the prod.

big thanks i come back to say if it totaly work or not.

 

Good game man it's the first attemp that success anytime for the moment.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

I mentioned all case but yeah it’s easyer when we see cases than when we dont.

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Btw i’m in bus right now so i cannot test.

but does these two regexp have lazy parameter ? 

I wont use regexp without lazy parameter when i can. 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

With this pattern : **** 

$cPattern = "(?is)\[([^\]]+)\]\[((?1))\]\[((?1))\]\[((?1))\]\[?([^\]]*)\]?.*?Bonjour,\s*(.+)\hvous.+email\h:\h([^""]+).+tél\.\h:\h([^""]*)"

It left a last thing to fix haha... 

 

It work in my exemple but not with the same exemple in real case. 

Maybe it s becose the structure is not same. 

 

But not even one letter is changing. So i dont figure out what's happenning. 

Look the Raw5 i have the message body when i dont want it. So i cannot extract name. Or i have to stringsplit again. WE 'RE SO CLOSE !!! ^^

image.png.4c03b0f6b0af711f6d1d4bf134a82e85.png

And a detail but i cant fix it with stringStripRight i guess. 

Row 6 ->  .com"-"

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

And with this pattern

 

$cPattern = "(?is)\[([^\]]+)\]\[((?1))\]\[((?1))\]\[((?1))\]\[?((?1))?.*?Bonjour,\s*(.+?)\hvous.+?email\h:\h(.+?)[\s-]+tél\.\h:\h(.+)?"

All working fine until now ..  i ll give more info after more test. 

But i have no doubt with mikell's pattern i wont have problem i bet on it !

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

@caramen
Hard words, but true:

Spoiler

If you would stop changinf the f*cking test strings instead of keep asking to change the pattern, this post should be done 1 page ago ffs.
In this post you described that:

  • the first pair of square brackets should contain 5 letters only, then in your test string you put asterisks ffs;
  • the second pair of square brackets should  contain PO or Autre or any other text;
  • the third pair of square brackets should contain from 3 digits;
  • the fourth pair of square brackets should contain a set of five strings;
  • the fifth pair of square brackets should contain folder number, which is a set of numbers and underscore, and this pair of brackets it's OPTIONAL;
  • the name is always before the word "vous";
  • the email is always there, but WON'T NEVER contains asterisks, so, don't put them in your test strings;
  • the number is always there, but it's OPTIONAL, and in your test string you put again those f*cking asterisks, when a number is usually composed by NUMBERS, spaces, minus signs, dot, slash, and so on.
Spoiler
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Global $arrStrings[6] = ["[XXXXX][PO][31][Demandeur] dghdfjgfdssfghchnique" & @CRLF & @CRLF & _                             ; String 1
                         "Bonjour," & @CRLF & _
                         "Charles HENRY vous envoie un message." & @CRLF & _
                         "J'ai un problème de toilette" & @CRLF & _
                         "Merci de m'aider" & @CRLF & _
                         "- email : someemail@somedomain.com" & @CRLF & _
                         "- tél. : 123456789", _
                         "[XXXXX][PO][31][Demandeur][161560_1550869077] dghdfjgzardytrezq technique" & @CRLF & @CRLF & _    ; String 2
                         "Bonjour," & @CRLF & _
                         "Charles HENRY vous envoie un message." & @CRLF & _
                         "J'ai un problème de toilette" & @CRLF & _
                         "Merci de m'aider" & @CRLF & _
                         "- email : someemail@somedomain.com" & @CRLF & _
                         "- tél. : 123456789", _
                         "[XXXXX][PO][31][Demandeur] dghdfjgfds technique" & @CRLF & @CRLF & _                              ; String 3
                         "Bonjour," & @CRLF & _
                         "Charles HENRY vous envoie un message." & @CRLF & _
                         "J'ai un problème de toilette" & @CRLF & _
                         "Merci de m'aider" & @CRLF & _
                         "- email : someemail@somedomain.com" & @CRLF & _
                         "- tél. : ", _
                         "[XXXXX][PO][31][Demandeur][161560_1550869077] Question technique   "& _                           ; String 4
                         "Bonjour,"& @CRLF & _
                         "PI****E GUE****A vous envoie ce message."& @CRLF & _
                         "Bonjour Dans un précédent message"& @CRLF & _
                         "Coordonnées :"& @CRLF & _
                         "- email : someemail@somedomain.com"& @CRLF & _
                         "- tél. : 123456789", _
                         "[XXXXX][PO][31][Demandeur] Question technique   "& _                                              ; String 5
                         "Bonjour,"& @CRLF & _
                         "PI**R****E GU*****A vous envoie ce message."& @CRLF & _
                         "Bonjour Dans un précédent message"& @CRLF & _
                         "Coordonnées :"& @CRLF & _
                         "- email : someemail@somedomain.com"& @CRLF & _
                         "- tél. : ", _
                         "[XXXXX][PO][31][Demandeur][161560_1550869077] Question technique   "& @CRLF & _                   ; String 6
                         "Bonjour,"& @CRLF & _
                         "PI****TTE GU****A vous envoie ce message."& @CRLF & _
                         "Bonjour Dans un précédent message"& @CRLF & _
                         "Coordonnées :"& @CRLF & _
                         "- email : someemail@somedomain.com"& @CRLF & _
                         "- tél. : "]

Global $strPattern = "(?is)" & _
                     "\[([a-z]{5})\]" & _                              ; Five Letters
                     "\[(PO|Autre|[^]]+)\]" & _                        ; PO or Autre or whatever you want
                     "\[(\d{1,3})\]" & _                               ; Three Digits
                     "\[(Demandeur|Opérateur|Prise|Instructeur)\]" & _ ; One of five Strings
                     "(?:\[(\w*)\])?" & _                              ; Folder Number, which is OPTIONAL
                     ".*?" & _
                     "Bonjour,\s" & _
                     "(.*?)vous.*?" & _                                ; Name and Surname
                     "\-\semail\s:\s([^\n]+)\s" & _                    ; Email
                     "\-\stél\.\s:\s([-\d]+)?"                        ; Telephone number, which is OPTIONAL

For $i = 0 To UBound($arrStrings) - 1 Step 1
    $arrResult = StringRegExp($arrStrings[$i], $strPattern, $STR_REGEXPARRAYGLOBALMATCH)
    If @error Then
        MsgBox($MB_ICONERROR, "", "Error: " & @error & @CRLF & "Extended: " & @extended)
    Else
        _ArrayDisplay($arrResult, "String #" & $i + 1)
    EndIf
Next

So, ffs, don't continuosely change your test string, because if you do so, all the patterns that you test will fail (from a non-generic point of view); otherwise, enjoy your incoherence, but stop annoying people.

:)

 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

I dont get it -.- ?

Someone posted this and it has been deleted ?

Or it s you preparing myself to get my mind explode by theses words x) ?

 

Anyway i tryed to be the more explicit as possible. I have confidential information and i put ** on them. 

I will just ignore that post. 

 

Anyway @mikell pattern is just perfect. 

With 2 attemps and the explanation provided.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Just now, FrancescoDiMuro said:

Change them, but be coerent with the requests you do (don't change a number with asterisks, or the pattern will fail).

This is obvius... 
I did that on the fly becose i posted the confidential information without hidding them. You can see in my first post it was not astrisks

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

You know what? Pattern is working . 

End of story. 

I dont like the turn that it take. 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

FOR PEOPLE WHO DONT WANT TO HELP IF YOU FEEL MY INFORMATION MISSING OR SOMTHING PASS YOUR WAY. 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

1 hour ago, caramen said:

Anyway @mikell pattern is just perfect. 

Glad I could help  ^_^

But please keep cool. Francesco's words are a bit rude but they are not totally false
He provided a lot of answers - which means a lot of time and thinking - while the requirements were continuously changing. This topic is now 3 pages long and could have been much shorter  ;)
The main rule when asking for regex help is : first consider all possible cases likely to occur, and when done then work to find the best pattern and ask for help. This is better as much for you (to get the correct answer faster) as for helpers (less time/energy to spend)

BTW I didn't provide explanations for my pattern. Lazy I am... so If you need some then feel free to ask  :)

Link to comment
Share on other sites

@FrancescoDiMuro @mikellDont worry me and Francesco are mate ;) We talk a lot in PM 

but i bet it 's not his words. 

 

It's not even possible for me to be hungry after him since he help me sooooooo much soooo much time

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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...