Jump to content

RegExp Help ^_^


Recommended Posts

@iamtheky since you said that, and you’re trying to help me. 

I’ m not able to have a critical mind about anything you can say. Dont be afraid and advise me as you want ;) 

I’m very late with regexp knowledge I will train it a lot at home I guess. 

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

@iamtheky Wooot man... wow.

 

Hey can you explain me how you're doing to get blank row(?*) without changing the order.

 

*Raw = line does i 'm using the correct word ?

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

@caramen

This is what I was meaning:

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

Global $strString = "[BLABLA][Autre][60][Demandeur][4567_987654]" & @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. : 0607080909"

Global $strPattern = "(?is)" & _
                     "\[[^]]+\]\[([a-z]+)\]\[(\d+)\]\[(Demandeur|Opérateur|Prise|Instructeur)\](?:\[(\w+)?\])?.*?" & _
                     "Bonjour,\s" & _
                     "(.*?)(?=vous).*?" & _
                     "\-\semail\s:\s([^\n]+)\s" & _
                     "\-\stél\.\s:\s([-\d]+)?"

Global $arrResult


$arrResult = StringRegExp($strString, $strPattern, $STR_REGEXPARRAYGLOBALMATCH)
If IsArray($arrResult) Then _ArrayDisplay($arrResult)

:)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

6 minutes ago, caramen said:

Hey can you explain me how you're doing to get blank row(?*) without changing the order.

Lazy quantifier wit captouring group.
Try to remove the [4567_987654] in the string, and you'll see a blank element in the array :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Daaaaamn Thanks  a  looot for that clear explanation guys ;)💗💗💗

 

Anyway i am very very busy at work i will train this later but i will not miss to do it it is so powerfull and the key to have more powerfull script.

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

 

@FrancescoDiMuro & @iamtheky I did it with that string :

And i got a invalid output :

[ANAH][PO][31][Demandeur][161560_1550869077] Question technique

And the return here :

image.png.ca6477b0cfe05a8ba208a7dd18ee631c.png

 

I'm sorry to ask again but the output is wrong i need to use the folder number in external URL after

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

 

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



Global $strString2 = "[BLABLA][Autre][60][Demandeur][4567_987654]" & @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. : 0607080909"

Global $strString3 = "[ANAH][PO][31][Demandeur][161560_1550869077] Question 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. :"


Global $strString4 = "[BLABLA][Autre][60][Demandeur]" & @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. : "



$aMatch = stringregexp(StringStripWS($strString3 , 8) , "\[.*?\]\[.*?\]\[(.*?)\]\[(.*?)\]\[*(.*?)\]*?Bonjour,([A-Z].+?)([A-Z].+?)vous.*?email:(.*?)-tél.:(.*?)\z",3)

_ArrayDisplay($aMatch)

String 3

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

Thx man and have a good day while we're waking up this morning ;)

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

Nop 😕 :  Or maybe i'm editing the wrong groupe ?

Global $strString3 = "[ANAH][PO][31][Demandeur][161560_1550869077] Question 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. :"

$aMatch = stringregexp(StringStripWS($strString3 , 8) , "\[.*?\]\[.*?\]\[(.*?)\]\[(.*?)\]\[*(.*?)\]*?Bonjour,([A-Z].+?)([A-Z].+?)vous.*?email:(.*?)-tél.:(.*?)\z",3)

_ArrayDisplay($aMatch)

And this : = IDEM

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

Global $strString3 = "[ANAH][PO][31][Demandeur][161560_1550869077] Question 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. :"

$aMatch = stringregexp(StringStripWS($strString3 , 8) , "\[.*?\]\[.*?\]\[(.*?)\]\[(.*?)\]\[(.*?)\]*?Bonjour,([A-Z].+?)([A-Z].+?)vous.*?email:(.*?)-tél.:(.*?)\z",3)

_ArrayDisplay($aMatch)

and this : null output

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

Global $strString3 = "[ANAH][PO][31][Demandeur][161560_1550869077] Question 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. :"

$aMatch = stringregexp(StringStripWS($strString3 , 8) , "\[.*?\]\[.*?\]\[(.*?)\]\[(.*?)\]\[(.*?)\]Bonjour,([A-Z].+?)([A-Z].+?)vous.*?email:(.*?)-tél.:(.*?)\z",3)

_ArrayDisplay($aMatch)

 

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 your pattern post #3 page 2 is working very fine i ll use this one dont spend more time in this ;) I ll try it and ome back after test if i have one error after multiple test with your code :)

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

The pattern should be changed from this

"\[.*?\]\[.*?\]\[(.*?)\]\[(.*?)\]\[*(.*?)\]*?Bonjour,([A-Z].+?)([A-Z].+?)vous.*?email:(.*?)-tél.:(.*?)\z"

to this

"\[.*?\]\[.*?\]\[(.*?)\]\[(.*?)\]\[(.*?)\]Bonjour,([A-Z].+?)([A-Z].+?)vous.*?email:(.*?)-tél.:(.*?)\z"

The error was in the captouring group before the "Bonjour" word :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

ahh ok.

Thought next line was ok.

I know i am still not that pro with AutoIT but i realy feel like a beginner when i start tuching RegExp 😜

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

@FrancescoDiMuro Bro, Your pattern work fine but nop if i play a bit with my first input line.

The @iamtheky Pattern is not working at all with the modification ...

arrrrrrrrrf

It always work with the text i am provinding but not with the next tests .... :(

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

To be extremly precise on what i can get i ll try again an other shot ^^ . I thought i already did that but ... I notice each time there is a particularity in my nexts attemps.

[XXXX][PO][50][Demandeur][161560_1550869077] RANDOM TEXT HERE


Bonjour,

SURNAME NAME vous envoie ce message :

BLABLABLA

BLABLABLA

BLABLABLA

RANDOM AMOUNT OF LINES

Coordonnées :
- email : AN@EMAIL.com
- tél. : 06 YY YY YY YY
  1. [XXXX] = Confidential constant name 5 letters
  2. [PO] = Can be PO or AUTRE ( or Maybe a random string ?)
  3. [50] = Random digit 0 to 999
  4. [Demandeur] = 5 different string possible
  5. [161560_1550869077]   = Random number in the same format = AAAAA_BBBBB
  6. RANDOM TEXT HERE = Random mono line text
  7. Bonjour,

           SURNAME NAME vous envoie ce message  = This will never change exept SURNAME NAME

           And some multiline random text after until point 8.

       8.- email : AN@EMAIL.com = "- email : "= constant

            & Random mail (".fr" , ".com" , ".ZZ"  )

       9.- tél. : YY YY YY YY YY =  "- tél. : " = Constant

             &  Y = Random number

So just to be sure but you already know, I need :

  1. -XXXX into a variable
  2. -Po into a variable
  3. - 50 into a variable
  4. -Demandeur into a variable
  5. -Folder number into a variable
  6. -SURNAME AND NAME into a variable
  7. - Email into a variable
  8. - Tel into a variable

Damn it i dont like to do this it's like i am shoping my code i terrybly sorry about that ...

Seem like we have everything here

Also I can provide my past working pattern in all my case before the change.

$pattern = '(?s).+?(\d+)\]\[([^\]]+).+?Bonjour,\s+(.+?) vous envoie.+?email : (\N+).+?tél. : (\N+)'

And that one when i was detecting no phone number :

$pattern = '(?s).+?(\d+)\]\[([^\]]+).+?Bonjour,\s+(.+?) vous envoie.+?email : (\N+)

But @iamtheky and @FrancescoDiMuro technique is very much better with the lazy parameter So i can have only one pattern and less code

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

@caramen
Now you can experiment whatever you want :)

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

Global $strString = "[XXXXX][Autre][60][Demandeur][4567_987654]SomeText" & @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. : 0607080909"

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

Global $arrResult


$arrResult = StringRegExp($strString, $strPattern, $STR_REGEXPARRAYGLOBALMATCH)
If IsArray($arrResult) Then _ArrayDisplay($arrResult)

 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Ok my first attemp is a fail.

I will spend you all confidential thing in PM let's see if it s my string that cause problem

 

@mikell Mr pro regexp can you help us 😛 ?

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