English
Source / code snippets

Multimatch

 

Michael
W.
Since I again over MatchPos and MatchLen stumbled be, nail I The multiple-Search with RegEx time here on...
CompileMarkSeparation
Proc MultiMatch$

    Parameters Maske$,Text$,StartPos&,MaxFundstellen&
    Declare found$[], idx&, old%, TLen&, savePos&, saveLen&, saveTxt$
    old% = Set("RegEx",1)
    idx& = 0
    Case StartPos& < 0 : StartPos& = 0
    Case MaxFundstellen& < 0 : MaxFundstellen& = 0
    TLen& = Len(Text$)

    While StartPos& < TLen&

        If InStr(Maske$, Text$, StartPos&) <> 0

            savePos& = %MatchPos
            saveLen& = %MatchLen
            saveTxt$ = $Match
            Inc StartPos&, savePos& + saveLen&
            found$[idx&] = saveTxt$
            Inc idx&
            Case (MaxFundstellen& <> 0) and (idx& >= MaxFundstellen&) : BREAK

        Else

            BREAK

        EndIf

    EndWhile

    Set("RegEx",old%)
    Return found$[]

EndProc

Proc MultiMatch2$

    Parameters Maske$,Text$,StartPos&,MaxFundstellen&
    Declare found$[], idx&, old%, TLen&, savePos&, saveLen&, saveTxt$
    old% = Set("RegEx",1)
    idx& = 0
    Case StartPos& < 0 : StartPos& = 0
    Case MaxFundstellen& < 0 : MaxFundstellen& = 0
    TLen& = Len(Text$)

    While StartPos& < TLen&

        If InStr(Maske$, Text$, StartPos&) <> 0

            savePos& = %MatchPos
            saveLen& = %MatchLen
            saveTxt$ = $Match
            found$[idx&] = Str$((StartPos&+savePos&)) + "|" + Str$(saveLen&) + "|" + saveTxt$
            Inc StartPos&, savePos& + saveLen&
            Inc idx&
            Case (MaxFundstellen& <> 0) and (idx& >= MaxFundstellen&) : BREAK

        Else

            BREAK

        EndIf

    EndWhile

    Set("RegEx",old%)
    Return found$[]

EndProc

Cls
Declare p%, gefunden$[], mask$,testfeld$
' Findet auch Uhrzeiten mit einstelliger Stundenzahl.
p% = 6' Startposition (die ersten 6 Zeichen sind Jahreszahl)
Print "Und nun alle Uhrzeiten : "
mask$ = "[0-9]{1,2}:[0-9]{2}"
testfeld$ = "201309,10,10:22,21:34,12:09,1:25"
gefunden$[] = MultiMatch$(mask$, testfeld$, p%, 0)

WhileLoop 0,SizeOf(gefunden$[])-1

    Case &Loop : Print ",";
    Print gefunden$[&Loop];

EndWhile

Print ""
gefunden$[] = MultiMatch$(mask$, testfeld$, p%, 2)

WhileLoop 0,SizeOf(gefunden$[])-1

    Case &Loop : Print ",";
    Print gefunden$[&Loop];

EndWhile

Print ""
mask$ = "(?i)~{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}~}"
testfeld$ = "\n{D1A5279D-B27D-4CD4-A05E-EFDD53D08E8D}\n{594ABD08-C02C-4827-8ABF-A128006848A3}\n" + \
"{B59511BD6A5F4DF09ECF562A108D8A2E}\n69593D62-71EA-4548-85E4-04FC71357423\n677E2553DD4D43B09DA77414DB1EB8EA\n\n" + \
"{99367d71-08ad-4aec-8e73-55ae151614f9}\n{5ba3bba3-729a-4717-88c1-b7c4b7ba80db}\n{7e9081b59a6d4cc1a8c347f69fb4198d}\n" + \
"0c74f13f-fa83-4c48-9b33-68921dd72463\nb4b2fb69c6244e5eb0698e0c6ec66618\n\nDE011585-7317-4C0D-A9AF-0AF2C5E61DB8}\n" + \
"{E8038A99-A409-490B-B11A-159A3496426D\n{D44EF4F4-280B47E5-91C7-261222A59621}\n{5EDEB36C-9006-467A8D04-AFB6F62CD7D2}\n" + \
"{D995AC86-5697-4683-A34F2B778BD837ED}\n{283B67B2-430F-4E6F-97E6-19041992-C1B0}\n2F2B15A5-2615-4748-BDABA124210F15EC\n" + \
"07D267AB-7126-45EB8FFC-51994D05F0B2"
Print "\nverifiziere GUID : (sollten 4 Treffer sein)";testfeld$
Print "\nErgebnis:"
gefunden$[] = MultiMatch$(mask$, testfeld$, 0, 0)

WhileLoop 0,SizeOf(gefunden$[])-1

    Print "  "; gefunden$[&Loop]

EndWhile

/*
Print "\nErgebnis:"
gefunden$[] = MultiMatch2$(mask$, testfeld$, 0, 0)
WhileLoop 0,SizeOf(gefunden$[])-1
Print "  "; gefunden$[&Loop]
EndWhile
*/
WaitInput
End
 
System: Windows 8/10, XProfan X4
Programmieren, das spannendste Detektivspiel der Welt.
07/05/15  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

4.042 Views

Untitledvor 0 min.
Erhard Wirth06/14/24
RudiB.04/26/22
p.specht11/20/21
Uwe Lang11/20/21
More...

Themeninformationen

this Topic has 1 subscriber:

Michael W. (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie