Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Delphi, Simple Text Parsing Function
zachtk8702
post 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.
Go to the top of the page
 
+Quote Post
iGuest
post 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
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Delphi Tutorial - Change Your Start Button Caption(4)
  2. Delphi - A Simple E-mail Notification System(4)
  3. Simple Parsing Functions(0)
  4. Getting Started In Vb 6(0)
  5. Php Sockets(4)
  6. Change / Modify The Title Bar Text In IE6 Or FF(3)
  7. Flatfile User Login/signup(24)
  8. Php - Randomize Web Title(5)
  9. How To Make Pixel Text With Paint!(10)
  10. How To Use Command Prompt As A Text Editor(6)
  11. User Permission Function [php](3)
  12. Php - Forms, Date And Include(0)


 



- Lo-Fi Version Time is now: 25th July 2008 - 09:37 AM