edel hat geschrieben:Es gibt keine moeglichkeit mit pb befehlen, man kann aber
die api von pcre benutzen.
Das was Marie23 machen möchte, ist doch auch mit PB-Befehlen
ganz leicht machbar:
(nicht vergessen, wir sind hier im *Anfänger*-Forum

)
Code: Alles auswählen
Dim result$(0)
If Not CreateRegularExpression(0,"h(.)llo")
Debug "Fehler: " + RegularExpressionError()
End
EndIf
Restore Datei
Repeat
Read line$ ; line$ = ReadString() um aus Datei zu lesen
count = ExtractRegularExpression(0, line$, result$())
If count
For i = 0 To count-1
match$ = Mid( result$(i), 2, 1 ) ; "h" und "llo" aus result$(i) entfernen
Debug match$
Next i
EndIf
Until line$ = "" ; Until EOF
DataSection
Datei:
Data.s "hallo"
Data.s "hello"
Data.s "hillo"
Data.s "hollo"
Data.s "hullo"
Data.s "h1llo h2llo h3llo h4llo"
Data.s ""
EndDataSection
Auch Dein Beispiel ist so machbar:
Code: Alles auswählen
Dim result$(0)
If Not CreateRegularExpression(0,"h(.)ll(.)")
Debug "Fehler: " + RegularExpressionError()
End
EndIf
Restore Datei
Repeat
Read line$ ; line$ = ReadString() um aus Datei zu lesen
count = ExtractRegularExpression(0, line$, result$())
If count
For i = 0 To count-1
match$ = result$(i)+" ("+Mid(result$(i),2,1)+") ("+Mid(result$(i),5,1)+")"
Debug match$
Next i
EndIf
Until line$ = "" ; Until EOF
DataSection
Datei:
Data.s " hhlld", "hallu", "hlll ", "hllld", "holla"
Data.s ""
EndDataSection
Die Position des gefunden Strings kann man auch ganz leicht
mit FindString(line$, result$(i), start_pos) bekommen, wenn man
es denn braucht.
@Marie23:
Schau Dir mal den ersten Code von mir hier an. Das umschreiben,
um die Zeilen aus einer Datei zu lesen, ist Deine Hausaufgabe.
Viel Spaß!
