Janilabo Posted August 26, 2012 Share Posted August 26, 2012 (edited) [scar]type TReplaceFlag = (rfReplaceAll, rfIgnoreCase); TReplaceFlags = set of TReplaceFlag; function ReplaceEx(Text, FindStr, ReplaceStr: string; Flags: TReplaceFlags; Offset: Integer): string; var i, tL, f: Integer; rgx_fs, tmp: string; m: TStrArray; r: TRegexMatchArray; begin Result := Text; tL := Length(Text); if ((tL < 1) or (Offset > tL) or (FindStr = ReplaceStr) or (Length(FindStr) > tL)) then Exit; Result := Copy(Text, Offset, ((tL - Offset) + 1)); if (Offset < 1) then Offset := 1; rgx_fs := '/' + PregQuote(FindStr) + '/'; if (rfIgnoreCase in Flags) then rgx_fs := (rgx_fs + 'i'); rgx_fs := (rgx_fs + 'm'); case (rfReplaceAll in Flags) of True: begin tmp := Result; SetLength(m, Round(tL div Length(FindStr))); while PregMatchEx(rgx_fs, tmp, r) do begin tmp := Replace(tmp, r[0].MatchedText, ''); m[f] := r[0].MatchedText; SetLength(r, 0); Inc(f); end; if (f > 0) then for i := 0 to (f - 1) do Result := Replace(Result, m, ReplaceStr); SetLength(m, 0); end; False: if PregMatchEx(rgx_fs, Result, r) then begin Result := (Copy(Result, 1, (r[0].Offset - 1)) + ReplaceStr + Copy(Result, (r[0].Offset + r[0].Length), (Length(Result) - (r[0].Offset + r[0].Length) + 1))); SetLength(r, 0); end; end; Result := (Copy(Text, 1, (Offset - 1)) + Result); end; var str: string; begin ClearDebug; str := 'Testing testing TESTing ... Testing, TESTing!'; WriteLn(ReplaceEx(str, 'Test', 'Tast', [rfReplaceAll], 2)); WriteLn(ReplaceEx(str, 'Test', 'Tast', [rfIgnoreCase, rfReplaceAll], 2)); WriteLn(ReplaceEx(str, 'Test', 'Tast', [rfIgnoreCase], 2)); WriteLn(ReplaceEx(str, 'Test', 'Tast', [], 2)); end.[/scar] Edited September 13, 2012 by Janilabo Fixed an infinite loop bug. Quote Link to comment Share on other sites More sharing options...
MarkD Posted August 27, 2012 Share Posted August 27, 2012 The SCAR version of string.replace, nice! Quote Link to comment Share on other sites More sharing options...
Janilabo Posted August 27, 2012 Author Share Posted August 27, 2012 Thanks MarkD. Quote Link to comment Share on other sites More sharing options...
AnthonyPhics Posted April 6 Share Posted April 6 オンライン カジノは、プレイヤーが自宅にいながらにしてポーカー、ルーレット、ブラックジャック、スロットなどのギャンブル ゲームを楽しむ機会を提供する仮想プラットフォームです。 オンラインカジノは、アクセスのしやすさ、ゲームの種類の多さ、そして大金を獲得する機会があるため、年々人気が高まっています。 オンラインカジノの主な利点は、利便性とアクセスしやすさです。 プレイヤーは、通常のカジノの営業時間に制限されず、いつでもゲームを楽しむことができます。 必要なのは、インターネットにアクセスできるデバイスと、カジノのウェブサイトにアクセスできることだけです。 これにより、プレイヤーは従来のカジノによくありがちなストレスや緊張を感じることなく、快適な環境でプレイすることができます。 オンラインカジノのもう1つの利点は、ゲームの選択肢が豊富なことです。 ユーザーは、それぞれ独自のルールと勝利の機会を提供する何百もの異なるゲームから選択できます。 技術革新のおかげで、オンライン ゲームのグラフィックとサウンドは高品質になり、プレイヤーは興奮と情熱の雰囲気に浸ることができます。 さまざまなゲームに加えて、オンライン カジノはプレーヤーにさまざまなボーナスやプロモーションも提供します。 これらは、スロットのフリースピン、プレイのための追加のお金、または貴重な賞品が得られる特別なトーナメントなどです。 このようなボーナスにより、勝利の可能性が高まり、ゲームがさらに楽しくなります。 もちろん、オンラインカジノでのプレイにはリスクがあります。 ギャンブルには依存性がある可能性があるため、自分の感情を監視し、支出をコントロールすることが重要であることを覚えておくことが重要です。 カジノはまた、責任あるゲーミングをサポートし、自己排除や賭け金制限の機会を提供します 星野莉子 av01 全体として、オンライン カジノはギャンブル愛好家にとって便利でエキサイティングなエンターテイメントを提供します。 幅広いゲーム、ボーナスの選択肢があり、いつでもプレイできるため、世界中のプレイヤーの間で人気が高まっています。 ただし、責任あるゲームと、ゲームが単なる楽しみと娯楽の源であるように自分の行動を制御する能力について覚えておくことが重要です。 Quote Link to comment Share on other sites More sharing options...
TerryKig Posted Tuesday at 04:20 PM Share Posted Tuesday at 04:20 PM bitcoin funds cryptomkt how to buy and sale bitcoin crypto ceo arrested toad coin how much bitcoin must i buy to buy 1000 electroneum crypto scam bitcoin fair value how do you buy a bitcoin upcoming binance listings how much is bitcoin taxed what does bitcoin halving mean for price osmo token eladgil a big day for crypto how to find new crypto coins how does crypto make money how far will shiba inu go tГіken bbtt crypto dao makr pfps for twitter amix stock price algorithmic crypto river bitcoin can you use credit card to buy bitcoin apt price crypto exchanges fees grayscale bitcoin trust stock 2-way bitcoin atm near me dummy version of buying bitcoins bittrex buy bitcoin with ethereum 1 dolar to bitcoin advantages of transferring bitcoin to a wallet ledgers crypto i want to buy bitcoin online 1 bitcoin in ghana cedis actual gold bitcoin $50 in bitcoin in 2013 loki crypto stake gambling owner pike finance 104 gh s z cash to bitcoin how does buying bitcoins in person work do crypto losses offset stock gains massa capital stake in crypto how to buy bitcoin with no id loom coin ethe discount to nav Quote Link to comment Share on other sites More sharing options...