Jump to content
Sign in to follow this  
ileandros

StringRegExp / StringSplit

Recommended Posts

ileandros

Hello there,

I am a few days now trying to understand this commands. I am reading the help files and examples but still nothing...

I got this command in my code which search in a file for lines

Local $aLines = StringRegExp($sLines, "(?:([^v]+)(?:v+|$))", 3) ; Lines to a zero-based array (blank lines not included).
and then i got a loop to find these lines.

My lines are like this

[22:53:48] "Leandros" Leaving
[22:53:50] "Leandros" Leaving
[22:53:53] "Shertaz" ?
[22:54:01] "Mirtid" any tips my friend?

The first two lines are basicly the same but the only thing changing is the time

[22:53:48] "Leandros" Leaving
[22:53:50] "Leandros" Leaving

there are 2 second difference in these lines and thats why my script wont find them. But they are still the same.

Is it able to make it find these same lines even if they have difference in the time?

Edit: Is it also able to make it avoid some lines starting like this?

[Open Server] .........
Edited by ileandros

I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
Skitty

I'm not very good at this regular expression stuff, but until someone with more know how on this posts, you can play with this?

This is probably what I'd do, I always just use the simple grab everything expression for stuff like this...

#include <Array.au3>
Local $Test[5] = ['[Open Server] .........','[22:53:48] "Leandros" Leaving','[22:53:50] "Leandros" Leaving','[22:53:53] "Shertaz" ?','[22:54:01] "Mirtid" any tips my friend?']
Local $aLines
For $I = 0 To 4
$aLines = StringRegExp($Test[$I], '[(.*):(.*):(.*)] "(.*)" (.*)', 3) ; Lines to a zero-based array (blank lines not included).
_ArrayDisplay($aLines)
Next

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
GPinzone

What kind of text are you looking to capture? It might be easier to help knowing what you want.


Gerard J. Pinzonegpinzone AT yahoo.com

Share this post


Link to post
Share on other sites
Skitty

What kind of text are you looking to capture? It might be easier to help knowing what you want.

Apparently they're IRC logs, they're all usually the same, consisting of time of entry, user name and things they said.


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
GPinzone

Yes, but what format does he want the text captured? Does he want the array to be "22:54:01", "Mirtid", "any tips my friend?"

the regex for that would be

[([^]]+)] "([^"]+)" (.*)

Or to be a more precise capture:

[([0-9]{2}:[0-9]{2}:[0-9]{2})] "([^"]+)" (.*)

Edited by GPinzone

Gerard J. Pinzonegpinzone AT yahoo.com

Share this post


Link to post
Share on other sites
ileandros

I am not actually writing a file it is just for the example.

I am taking a text that is writen in a window i have and the text inside it is similar as this one i am posting.

Just making it this way so you can understand.

Edit: I just can seem to understand it...

Edited by ileandros

I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
ileandros

Here is a better script to understand it

#include <Array.au3>
#include <File.au3>

Local $sFile =  "[22:53:48] Leandros Leaving"&@CR&"[22:53:48] Leandros Leaving"&@CR&"[22:53:53] Shertaz ?"&@CR&"[22:54:01] Mirtid any tips my friend?"
$sFiles = run("notepad.exe")
Sleep(2000)
Send($sFile)
Sleep(1000)
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Local $sWinTitle = "Notepad" ; "WordPad" ;
If WinExists($sWinTitle) Then
    WinActivate($sWinTitle)
    WinWaitActive($sWinTitle)
    Local $sLines = ControlGetText($sWinTitle, "", "") ; 3rd parameter, "", means Active Control.
    Local $aLines = StringRegExp($sLines, "(?:([^v]+)(?:v+|$))", 3) ; Lines to a zero-based array (blank lines not included).
    ;Local $aLines = StringSplit(StringStripCR($sLines), @LF, 2) ; Lines to a zero-based array (blank lines included).
    If IsArray($aLines) Then
        Local $sRes = ""
        ;_ArrayDisplay($aLines)
        For $i = 0 To UBound($aLines) - 1
            For $j = 0 To UBound($aLines) - 1
                If ($i <> $j) And $aLines[$i] == $aLines[$j] Then ; Check if the "$i"'th element exists any where else in the whole array.
                    $sRes &= StringFormat("Line %3d/ is:  ""%s""n", $i + 1, $aLines[$i])
                    ExitLoop
                EndIf
            Next
        Next
        If $sRes = "" Then
            MsgBox(0, "Lines", "There are no lines.", 2)
        Else
            MsgBox(0, "Lines", $sRes)
        EndIf
    Else
        MsgBox(64, "Attention", $sWinTitle & " has no lines present.", 2)
    EndIf
Else
    MsgBox(64, "Attention", $sWinTitle & " window not running.", 2)
EndIf
Edited by ileandros

I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
Malkey

With association with , this example will call lines duplicate, when lines have the same text and have a time difference of three (3) minutes or less.

;#include <Array.au3>
;#include <File.au3>
#include <Date.au3>

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

Local $sWinTitle = "Notepad" ; "WordPad" ;
Local $sFile = _
        "[22:53:48] Leandros Leaving" & @CRLF & _
        "[22:53:50] Leandros Leaving" & @CRLF & _
        "[22:53:53] Shertaz ?" & @CRLF & _
        "[22:54:01] Mirtid any tips my friend?"
Local $sTemp, $TimeDiff, $Time_i, $Time_j, $TimeDiff
Local $sFiles = Run("notepad.exe")
WinWaitActive($sWinTitle)
;Send($sFile)
ControlSetText($sWinTitle, "", "", $sFile)

If WinExists($sWinTitle) Then
    WinActivate($sWinTitle)
    WinWaitActive($sWinTitle)
    Local $sLines = ControlGetText($sWinTitle, "", "") ; 3rd parameter, "", means Active Control.
    Local $aLines = StringRegExp($sLines, "(?:([^v]+)(?:v+|$))", 3) ; Lines to a zero-based array (blank lines not included).
    ;Local $aLines = StringSplit(StringStripCR($sLines), @LF, 2) ; Lines to a zero-based array (blank lines included).
    If IsArray($aLines) Then
        Local $sRes = ""
        ;_ArrayDisplay($aLines)
        For $i = 0 To UBound($aLines) - 1
            $sTemp = StringRegExpReplace($aLines[$i], "([.*])(.*)", "$2")
            For $j = 0 To UBound($aLines) - 1

                If ($i <> $j) And (StringRegExpReplace($aLines[$j], "([.*])(.*)", "$2") == $sTemp) Then ; Check if the "$i"'th element exists any where else in the whole array.
                    ; --------- Get time difference -------------
                    $Time_i = StringRegExpReplace($aLines[$i], "[(.*)](.*)", "$1")
                    $Time_j = StringRegExpReplace($aLines[$j], "[(.*)](.*)", "$1")
                    $TimeDiff = Abs(_DateDiff("s", "2012/01/01 " & $Time_i, "2012/01/01 " & $Time_j))
                    ;Note If the time difference spans the end of the day, for example, "23:59:59" and "00:00:01", a wrong result, 86398, will occur - not 2 secs.
                    ;ConsoleWrite($Time_i & @LF)
                    ;ConsoleWrite($Time_j & @LF)
                    ;ConsoleWrite($TimeDiff & @LF)
                    ; ---------> End of Get time difference -------------

                    If $TimeDiff <= 180 Then ; 180 = 3 minutes
                        $sRes &= StringFormat("Line %3d/ is:  ""%s""n", $i + 1, $aLines[$i])
                        ExitLoop
                    EndIf
                EndIf
            Next
        Next
        If $sRes = "" Then
            MsgBox(0, "Lines", "There are no lines.", 2)
        Else
            MsgBox(0, "Lines", $sRes)
        EndIf
    Else
        MsgBox(64, "Attention", $sWinTitle & " has no lines present.", 2)
    EndIf
Else
    MsgBox(64, "Attention", $sWinTitle & " window not running.", 2)
EndIf

Share this post


Link to post
Share on other sites
ileandros

With association with , this example will call lines duplicate, when lines have the same text and have a time difference of three (3) minutes or less.

;#include <Array.au3>
;#include <File.au3>
#include <Date.au3>

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

Local $sWinTitle = "Notepad" ; "WordPad" ;
Local $sFile = _
        "[22:53:48] Leandros Leaving" & @CRLF & _
        "[22:53:50] Leandros Leaving" & @CRLF & _
        "[22:53:53] Shertaz ?" & @CRLF & _
        "[22:54:01] Mirtid any tips my friend?"
Local $sTemp, $TimeDiff, $Time_i, $Time_j, $TimeDiff
Local $sFiles = Run("notepad.exe")
WinWaitActive($sWinTitle)
;Send($sFile)
ControlSetText($sWinTitle, "", "", $sFile)

If WinExists($sWinTitle) Then
    WinActivate($sWinTitle)
    WinWaitActive($sWinTitle)
    Local $sLines = ControlGetText($sWinTitle, "", "") ; 3rd parameter, "", means Active Control.
    Local $aLines = StringRegExp($sLines, "(?:([^v]+)(?:v+|$))", 3) ; Lines to a zero-based array (blank lines not included).
    ;Local $aLines = StringSplit(StringStripCR($sLines), @LF, 2) ; Lines to a zero-based array (blank lines included).
    If IsArray($aLines) Then
        Local $sRes = ""
        ;_ArrayDisplay($aLines)
        For $i = 0 To UBound($aLines) - 1
            $sTemp = StringRegExpReplace($aLines[$i], "([.*])(.*)", "$2")
            For $j = 0 To UBound($aLines) - 1

                If ($i <> $j) And (StringRegExpReplace($aLines[$j], "([.*])(.*)", "$2") == $sTemp) Then ; Check if the "$i"'th element exists any where else in the whole array.
                    ; --------- Get time difference -------------
                    $Time_i = StringRegExpReplace($aLines[$i], "[(.*)](.*)", "$1")
                    $Time_j = StringRegExpReplace($aLines[$j], "[(.*)](.*)", "$1")
                    $TimeDiff = Abs(_DateDiff("s", "2012/01/01 " & $Time_i, "2012/01/01 " & $Time_j))
                    ;Note If the time difference spans the end of the day, for example, "23:59:59" and "00:00:01", a wrong result, 86398, will occur - not 2 secs.
                    ;ConsoleWrite($Time_i & @LF)
                    ;ConsoleWrite($Time_j & @LF)
                    ;ConsoleWrite($TimeDiff & @LF)
                    ; ---------> End of Get time difference -------------

                    If $TimeDiff <= 180 Then ; 180 = 3 minutes
                        $sRes &= StringFormat("Line %3d/ is:  ""%s""n", $i + 1, $aLines[$i])
                        ExitLoop
                    EndIf
                EndIf
            Next
        Next
        If $sRes = "" Then
            MsgBox(0, "Lines", "There are no lines.", 2)
        Else
            MsgBox(0, "Lines", $sRes)
        EndIf
    Else
        MsgBox(64, "Attention", $sWinTitle & " has no lines present.", 2)
    EndIf
Else
    MsgBox(64, "Attention", $sWinTitle & " window not running.", 2)
EndIf

Well man i dont have words... I opened this thread because i didnt want to get you in so much trouble. I dont know how to thank you...

And it will take time for me to understand this code ;)


I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
ileandros

I think i found a bug. I dont know if its ready a bug but something is going wrong here.

Change the Local $sFile to this and try it

Local $sFile = _
        "[02:38:25] <Inser>  hello  " & @CRLF & _
        "[03:00:55] <tsakil> enjoy ] <iVespa>" & @CRLF & _
        "[02:43:25] <Inser>  hello  " & @CRLF & _
        "[03:04:54] <tsakil> ] hello  enjoy ] <iVespa>" & @CRLF & _
        "[22:54:01] <Mirtid> any tips my friend?"

It doesnt find the 1st and the 3rd line because of the time that is more that 180 secs but why it says that the 2ond and 4th lines are duplicated????

Edited by ileandros

I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
Malkey

I think i found a bug. I dont know if its ready a bug but something is going wrong here.

Change the Local $sFile to this and try it

Local $sFile = _
        "[02:38:25] <Inser>  hello  " & @CRLF & _
        "[03:00:55] <tsakil> enjoy ] <iVespa>" & @CRLF & _
        "[02:43:25] <Inser>  hello  " & @CRLF & _
        "[03:04:54] <tsakil> ] hello  enjoy ] <iVespa>" & @CRLF & _
        "[22:54:01] <Mirtid> any tips my friend?"

It doesnt find the 1st and the 3rd line because of the time that is more that 180 secs but why it says that the 2ond and 4th lines are duplicated????

You are correct. There is a mistake in the Reg Exp pattern. By default ".*" is greedy, and the question mark makes ".*?" un-greedy. In the RE patterns I had "([.*])". This will capture the first open square bracket and everything (including any close square brackets) up to and including the last close square bracket in the test string because ".*" is greedy.

If I had correctly used "([.*?])", this will capture the first open square bracket and everything up to and including the first close square bracket that is encountered from left to right in the test string.

At the time of writing the RE pattern, I expected there would be only one pair of square brackets per line. This would make the greediness of "([.*])" irrelevant.

To explain the RE pattern, "(?;)[^v]+)(?:v+|$))", in the StringRegExp($sLines, "(?:)[^v]+)(?:v+|$))", 3) function:-

(?:...) This outside encompassing non-capturing group is not necessary. It represents one line.

Inside that non-capturing group is "([^v]+)(?:v+|$)" . This has two groups, a capture group (this is the text we want), and a non-capturing group containing characters we do not want to capture.

([^v]+) will capture all characters that are not a vertical white-space character - a line-feed (@LF) or carriage return (@CR).

(?:v+|$) At the end of each line is one or more vertical white-space characters, "v+" or, "|", the end of the test string, "$"

Notice this example uses string manipulation functions other than StringRegExpReplace.

Because the first 10 characters on each line will be in the format "[nn:nn:nn]" , StringTrimLeft, and StringMid functions can be used.

;#include <Array.au3>
;#include <File.au3>
#include <Date.au3>

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

Local $sWinTitle = "Notepad" ; "WordPad" ;
#cs
Local $sFile = _
        "[22:53:48] Leandros Leaving" & @CRLF & _
        "[22:53:50] Leandros Leaving" & @CRLF & _
        "[22:53:53] Shertaz ?" & @CRLF & _
        "[22:54:01] Mirtid any tips my friend?"
                #ce
Local $sFile = _
        "[02:38:25] <Inser>  hello  " & @CRLF & _
        "[03:00:55] <tsakil> enjoy ] <iVespa>" & @CRLF & _
        "[02:43:25] <Inser>  hello  " & @CRLF & _
        "[03:04:54] <tsakil> ] hello  enjoy ] <iVespa>" & @CRLF & _
        "[22:54:01] <Mirtid> any tips my friend?"
Local $sTemp, $TimeDiff, $Time_i, $Time_j, $TimeDiff
Local $sFiles = Run("notepad.exe")
WinWaitActive($sWinTitle)
;Send($sFile)
ControlSetText($sWinTitle, "", "", $sFile)

If WinExists($sWinTitle) Then
    WinActivate($sWinTitle)
    WinWaitActive($sWinTitle)
    Local $sLines = ControlGetText($sWinTitle, "", "") ; 3rd parameter, "", means Active Control.
    Local $aLines = StringRegExp($sLines, "(?:([^v]+)(?:v+|$))", 3) ; Lines to a zero-based array (blank lines not included).
    ;Local $aLines = StringSplit(StringStripCR($sLines), @LF, 2) ; Lines to a zero-based array (blank lines included).
    If IsArray($aLines) Then
        Local $sRes = ""
        ;_ArrayDisplay($aLines)
        For $i = 0 To UBound($aLines) - 1
            ;$sTemp = StringRegExpReplace($aLines[$i], "([.*?])(.*)", "$2") ;<- Corrected to be un-greedy (allows for extra "]")
            $sTemp = StringTrimLeft($aLines[$i], 10)
            For $j = 0 To UBound($aLines) - 1

                ;If ($i <> $j) And (StringRegExpReplace($aLines[$j], "([.*?])(.*)", "$2") == $sTemp) Then ; Check if the "$i"'th element exists any where else in the whole array.
                If ($i <> $j) And (StringTrimLeft($aLines[$j], 10) == $sTemp) Then ; Check if the "$i"'th element exists any where else in the whole array.
                    ; --------- Get time difference -------------
                    ;$Time_i = StringRegExpReplace($aLines[$i], "[(.*?)](.*)", "$1") ;<- Corrected to be un-greedy (allows for extra "]")
                    ;$Time_j = StringRegExpReplace($aLines[$j], "[(.*?)](.*)", "$1") ;<- Corrected to be un-greedy (allows for extra "]")
                    $Time_i = StringMid($aLines[$i], 2, 8)
                    $Time_j = StringMid($aLines[$j], 2, 8)
                    $TimeDiff = Abs(_DateDiff("s", "2012/01/01 " & $Time_i, "2012/01/01 " & $Time_j))
                    ;Note If the time difference spans the end of the day, for example, "23:59:59" and "00:00:01", a wrong result, 86398, will occur - not 2 secs.
                    ConsoleWrite($Time_i & @LF)
                    ConsoleWrite($Time_j & @LF)
                    ConsoleWrite($TimeDiff & @LF)
                    ; ---------> End of Get time difference -------------

                    If $TimeDiff <= 180 Then ; 180 = 3 minutes
                        $sRes &= StringFormat("Line %3d/ is:  ""%s""n", $i + 1, $aLines[$i])
                        ExitLoop
                    EndIf
                EndIf
            Next
        Next
        If $sRes = "" Then
            MsgBox(0, "Lines", "There are no lines.", 2)
        Else
            MsgBox(0, "Lines", $sRes)
        EndIf
    Else
        MsgBox(64, "Attention", $sWinTitle & " has no lines present.", 2)
    EndIf
Else
    MsgBox(64, "Attention", $sWinTitle & " window not running.", 2)
EndIf

Share this post


Link to post
Share on other sites
ileandros

Thank you very much for the answer. It was very helpfull belive me. So ur using $sTemp = StringTrimLeft($aLines[$i], 10) which it allows me to use more " ] " and ur using $Time_i = StringMid($aLines[$i], 2, 8) to catch the date right?? This is an easier way as i see and since the writing style inside stays stable it works like a charme. What i want to do ,which ur replaced it at this last post, is this:

Local $sFile = _
        "[02:38:25] <inser>  hello  " &amp; @CRLF &amp; _
        "[03:00:55] <tsakil> enjoy ] <ivespa>" &amp; @CRLF &amp; _
        "[02:43:25] <inser>  hello  " &amp; @CRLF &amp; _
        "[03:04:54] <tsakil> ] hello  enjoy ] <ivespa>" &amp; @CRLF &amp; _
        "[22:54:01] <mirtid> any tips my friend?"

As you can understand the first part represents the Date i write, the second part represents the Name and the third part represents the "Things" i write.

I would easly use StringMid if the names are all the same but they are not.

Before u were using this $Time_i = StringRegExpReplace($aLines[$i], "[(.*?)](.*)", "$1") which didnt allowed me to use more " ] " as i understand.

To be honest i am reading the StringRegExp function and the help files but i cant understand it very much.

How can i catch the name? How can i catch these "<" ">" so i find the name? I wanna test the name if it exists 3 or more times betwen the duplicated names but i dont know how to catch it.. I triend "(? ;)[^v]+)(?:v+|$))" which had no succes.</mirtid></ivespa></tsakil></inser></ivespa></tsakil></inser>

Edited by ileandros

I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
Malkey

.... So ur using $sTemp = StringTrimLeft($aLines[$i], 10) which it allows me to use more " ] "....

No, the StringTrimLeft() function was just an alternative function to use instead of using StringRegExpReplace(). All the commented out command lines in my previously posted script work using an alternate function.

....

Before u were using this $Time_i = StringRegExpReplace($aLines[$i], "\[(.*?)\](.*)", "$1") which didnt allowed me to use more " ] " as i understand.

....

No, before I was using this $Time_i = StringRegExpReplace($aLines[$i], "\[(.*)\](.*)", "$1") which didn't allow the use of more " ] ", because of the missing, all important, question mark.

See AutoIt help file > Under "StringRegExp" function > Scroll down to "Repeating Characters" table > At the bottom of table see "? (after a repeating character)". It is this question mark I have been referring to as making ".*?" un-greedy.

I am not referring to the question mark that is one above that follows a character, set or group.

In fact, the immediate above quote is very wrong because $Time_i = StringRegExpReplace($aLines[$i], "\[(.*?)\](.*)", "$1") allows the use of more " ] ", because the question mark following a repeating character is present.

May clarity replace confusion with regard to regular expressions.

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  

  • Similar Content

    • therks
      By therks
      So I have this pattern: 
      ^(?:(\d+)|(\d+):(\d+)|(\d+):(\d+):(\d+))$ And I'm expecting (depending on input) to get a 1, 2 or 3 index array (or @error for invalid input).
      But instead I get this:
      #include <Debug.au3> Func Test($String) _DebugArrayDisplay(StringRegExp($String, '^(?:(\d+)|(\d+):(\d+)|(\d+):(\d+):(\d+))$', 1)) EndFunc Test('10') ; Results (normal, expected): ; Row 0|10 Test('10:20') ; Results (extra blank index): ; Row 0| ; Row 1|10 ; Row 2|20 Test('10:20:30') ; Results (three blank indices): ; Row 0| ; Row 1| ; Row 2| ; Row 3|10 ; Row 4|20 ; Row 5|30 Is this normal? Should I just code around it, or is there a better way to do what I'm looking for?
      I also tried reversing my regex, but it was even uglier results:
      #include <Debug.au3> Func Test($String) _DebugArrayDisplay(StringRegExp($String, '^(?:(\d+):(\d+):(\d+))|(\d+):(\d+)|(\d+)$', 1)) EndFunc Test('10') ; Results (yuck): ; Row 0| ; Row 1| ; Row 2| ; Row 3| ; Row 4| ; Row 5|10 Test('10:20') ; Results (slightly better): ; Row 0| ; Row 1| ; Row 2| ; Row 3|10 ; Row 4|20 Test('10:20:30') ; Results (nice): ; Row 0|10 ; Row 1|20 ; Row 2|30  
    • Deye
      By Deye
      Hi,
      I want to add any needed conditions to the StringRegExp command so it can pull out only  "File.au3", "WinAPIFiles.au3", "Test.bmp" into the array
      #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include 'WinAPIFiles.au3' #include "File.au3" ; Script Start - Add your code below here Local $bFileInstall = False ; Change to True and ammend the file paths accordingly. ; This will install the file C:\Test.bmp to the script location. If $bFileInstall Then FileInstall("C:\Test.bmp", @ScriptDir & "\Test.bmp") $sFile = FileRead(@ScriptFullPath) $aResults = StringRegExp($sFile, "(?i)(FileInstall\s*|include\s*)(.*)", 3) _ArrayDisplay($aResults) Thanks In Advance
      Deye
    • FMS
      By FMS
      Hello,
      Does somebody knows a quick way to split eash word to an array in a text?
      I've a text and want to have each word in that text in an array.

      I tried to get in some way multiple seperators inside stringsplit but couldn't get it to work.
      I hope to get an array like :
      $aArray[0] = "PARIJS"
      $aArray[1] = "AFN"
      $aArray[2] = "Air"
      ....
      sample text: PARIJS (AFN) - Air France-KLM heeft de financieel directeur van het Franse nuts- en vervoersbedrijf Veolia, Philipe Capron, in het vizier om de nieuwe topman van de luchtvaartcombinatie te worden. Volgens de krant La Tribune wordt Capron als favoriet beschouwd om de topfunctie te gaan vervullen. AdChoices Advertentie Volgens bronnen tegen La Tribune is de keuze voor Capron zelfs al gemaakt door Air France-KLM en zal zijn voordracht volgende week worden voorgelegd aan de raad van toezicht bij het bedrijf. Capron zou dan de opvolger worden van de opgestapte topman Jean-Marc Janaillac. In mei trad Janaillac af nadat het hem niet was gelukt buiten de bonden om zaken te doen met het eigen personeel. Sindsdien heeft een interim-bestuur de dagelijkse leiding. De zestigjarige Capron is sinds 2014 financieel directeur bij Veolia. Daarvoor werkte hij onder meer bij mediaconcern Vivendi. Minder macht Overigens zijn er ook geruchten dat de nieuwe topman van Air France-KLM direct een zetel zou krijgen in de raad van commissarissen van KLM. Binnen de Nederlandse divisie, die juist alles op alles zet om minder macht naar Parijs te laten vloeien, is men volgens ingewijden verbolgen over die gang van zaken. ,,Stank voor dank", zo klinkt het in de wandelgangen. Eerder zou Janaillac ook al hebben geprobeerd om een dikkere vinger in de pap te krijgen bij KLM, dat door de bank genomen beter presteert dan haar Franse zustermaatschappij. Dit lukte eerder niet, onder meer door inmenging van het Nederlandse kabinet. AdChoices Advertentie Geruchten Een woordvoerder van Air France-KLM wilde niet reageren op de geruchtenstroom. Het concern gaat er vanuit dat binnen afzienbare tijd een nieuwe bestuursvoorzitter benoemd zal worden. Minister Cora van Nieuwenhuizen (Infrastructuur) wilde evenmin ingaan op geruchten. ,,Ik heb hierover nog geen contact gehad met KLM, dus dat wil ik eerst even afwachten'', zei ze. Tweede Kamerleden spraken deze week tijdens een debat nog maar eens hun zorg uit over de ontwikkelingen bij Air France-KLM. Zij drongen aan op herbevestiging van oude afspraken over de relatief zelfstandige positie van KLM binnen de groep.>Exit code: 0 Time: 28.52  
    • FroVN
      By FroVN
      i have a text : <Name>Jonh</Name>.<Age>15</Age>
      how i can get Jonh and 15 in one stringregexp? pls give me example
    • therks
      By therks
      I'm looking for a regex genius, cus I'm stumped when it comes to assertions.
      So what I have now, is this regular expression: ([^|=]+)=([^|]+)
      It takes a string (user input) of keys=values separated by pipes (ie: "param=value|param=value") and splits them into an array.
      Example:
      $vParamData = 'example=value|fruit=apple|phrase=Hello world' $aRegEx = StringRegExp($vParamData, '([^|=]+)=([^|]+)', 3) ; Result ; [0] => example ; [1] => value ; [2] => fruit ; [3] => apple ; [4] => phrase ; [5] => Hello world So that's working fine, but I'm wondering if there's also a way I could have this capture escaped pipes instead of splitting by them.
      ie:
      $vParamData = 'pipe test=this \| is a pipe|example=value' $aRegEx = StringRegExp($vParamData, '([^|=]+)=([^|]+)', 3) ; I'm getting this: ; [0] => pipe test ; [1] => this \ ; [2] => example ; [3] => value ; But I'd like a result like this: ; [0] => pipe test ; [1] => this \| is a pipe ; [2] => example ; [3] => value Is there some pattern that would accomplish this, or am I better off parsing it some other way?
×