|
|
|
|
![]() ![]() |
Feb 10 2005, 03:37 AM
Post
#1
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 81 Joined: 3-August 04 Member No.: 609 |
Because parsing is such an integral part of string manipulation, I took the time to make a quick and simple parse function.
For you VBers, Delphi is a derivative of Pascal...it's powerful, simple, and (best of all) doesn't need external component (eg: ocx files). Hence the code: Code: function TForm1.SimpleParse(MainString, BeginString, EndString: string): string; var PosBeginString: integer; PosEndString: integer; begin PosBeginString := Pos(BeginString, MainString) + Length(BeginString); PosEndString := Pos(EndString, MainString); Result := Copy(MainString, PosBeginString, PosEndString - PosBeginString); end; For example, the code: Code: ShowMessage(SimpleParse('The quick brown fox jumped over the lazy dog.', 'brown', 'jumped')); ...will return the string: ' fox ' Notes: 1) The instance variables PosBegin/EndString aren't needed if you replace their assigned values in the actual Copy function. 2) You don't necessarily need the function to parse. You can take those three lines (or single line) of code and put it in a procedure. That is all. I may make a parsing function that parses multiple items in the future. Enjoy. |
|
|
|
Dec 2 2007, 09:33 AM
Post
#2
|
|
|
Trap Double Mocha Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,360 Joined: 21-September 07 Member No.: 50,369 |
I was actually looking for a shoutbox which doesn't need php or MySql
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 25th July 2008 - 09:37 AM |