![]() |
Regular Expressions letzten href vor Stichwort finden
Hallo Leute ich möchte die letzte "href" Zeichenkette vor einem Variablen Stichwort ermitteln.
Mein Problem ist das mehrere "href" im string vorkommen. daher funtioniert
Delphi-Quellcode:
nicht da dann alles vom ersten statt vom letztmöglichem "href" gematcht wird.
//with TRegEx.Match(mmo1.Text,'href(.*?)' +s,[roIgnoreCase,roSingleLine]) do
// with TRegEx.Match(mmo1.Text,'(?<!(href))(?<=(href))(.+?)' +s,[roIgnoreCase,roSingleLine]) do //with TRegEx.Match(mmo1.Text,'[^(href)]?(.*?)' +s,[roIgnoreCase,roSingleLine]) do //with TRegEx.Match(mmo1.Text,'^(href)(.*?)' +s,[roIgnoreCase,roSingleLine]) do //with TRegEx.Match(mmo1.Text,'([^(href)].*?)' +s,[roIgnoreCase,roSingleLine]) do //with TRegEx.Match(mmo1.Text,'(.[^(href)]*?)' +s,[roIgnoreCase,roSingleLine]) do //with TRegEx.Match(mmo1.Text,'[^(href)](.*?)' +s,[roIgnoreCase,roSingleLine]) do Da ich neben dem schreiben x möglichkeiten probierte und nun eine funktionierte, poste ich die Lösung gleich mit. Eventuell gibts ja noch ahnungslose wie mich.
Delphi-Quellcode:
with TRegEx.Match(mmo1.Text,'href(?(?!.*href.*).*)' +s,[roIgnoreCase,roSingleLine]) do
begin if Success then begin mmo2.Lines.Add('sucsess'); mmo2.Lines.Add(Value); end; end; |
AW: Regular Expressions letzten href vor Stichwort finden
Probiers mal mit PosEx().
|
AW: Regular Expressions letzten href vor Stichwort finden
Man sollte kein RegEx nehmen, um HTML zu verarbeiten. Probiers mal mit einem DOM-Parser.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:39 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz