May 17, 2008

Delphi - Simple Text Parsing Function

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

Delphi - Simple Text Parsing Function

zachtk8702
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.

 

 

 


Reply

Trap FeedBacker
I was actually looking for a shoutbox which doesn't need php or MySql

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. text command parser delphi sample - 0.81 hr back.
  2. function - 3.12 hr back.
  3. delphi parsing text - 13.41 hr back.
  4. delphi text parsen - 15.76 hr back.
  5. delphi fo php example - 18.94 hr back.
  6. delphi parsing text - 19.25 hr back.
Similar Topics

Keywords : delphi, simple, text, parsing, function

  1. Php - Forms, Date And Include
    Working with POST and GET and also the Date() function (0)
  2. User Permission Function [php]
    Determining User Permissions (3)
    There have been several recent request for methods to restrict access to various pages on a web-site
    based on User Permissions in sites that have a Login System in place. Here is some code showing one
    method to restrict access by providing a sub-set of your site's links based on the User's
    permissions. In this demonstration, I have defined a string for each 'level of user'
    determining which set(s) of links they can view on your site. Normal MySql procedure would be to
    read the User's permission level from a record in the database. For the purpose of ....
  3. How To Use Command Prompt As A Text Editor
    (5)
    In this tutorial, I will show you how you can use Command Prompt to create text files. It is very
    simple and you can also use it to write output from a command into a text file. This can be
    particularly useful when you need documentation from a DOS program in a text file when you use the
    help command or something similar. In order to do this you simply use this DOS command. echo
    Text >> test.txt This will create a new text file called test and echo the contents into it. If
    we wanted to write a 2 line document, we could do something like: echo Hello >> test.txt e....
  4. How To Make Pixel Text With Paint!
    Cool if you don't have photoshop or any of those (10)
    First you need a font called minimum +1 Follow these instructions CAREFULLY on how to install the
    font. If you're using firefox RIGHT CLICK on the link below and select "save link as"
    DOWNLOAD LINK READ THE ABOVE STUFF BEFORE CLICKING ON ME!!!! Then save it in
    your documents. Don't worry if firefox "quits" the download. As long as it is in your documents
    you're fine. ON IE.... Right click on link above and select "save traget as" Then go to
    start and open up "my documents". The font should be there. Keep that window open g....
  5. Php - Randomize Web Title
    using arrays and the random function (5)
    PHP - Randomize Web Title with the rand function... Define the variables numbers we start at number
    0 CODE <?php $title[0] = "Web title 0"; // Title 0
    $title[1] = "Web title 1"; // Title 1 $title[2] = "Web title
    2"; // Title 2 $title[3] = "Web title 3"; // Title 3
    $title[4] = "Web title 4"; // Title 4 ?> now we use the rand()
    function to get a randomize the web title. rand(0, 4) means we start at 0 and end at 4 i can get
    0,1,2,3,4 one of those. ....
  6. Flatfile User Login/signup
    Uses text files only (compatable with forums and message system) (23)
    With this tutorial, you will learn how to create a textfile login script. This user membership
    script is for use also with my forums and message system scripts. I will also give you the scripts
    to make it so that people can change their profiles. Ok, The first thing we need to do is make the
    database. To do this, create a blank text file called 'userdata.txt' , make sure it is ALL
    LOWER-CASE. Edit this file and put
    '**username|##|password|##|email|##|rank|##|userid|##|name|##|picture**'. This will not be
    used, however it will give you an idea of how the....
  7. Change / Modify The Title Bar Text In IE6 Or FF
    custom text in titlebar in ie or firefox (3)
    Changing The Text In The Bar (IE and Firefox Only) This will allow you to change the text in
    the title bar of either msie6 (may work for ie7 beta or earlier versions) and mozilla firefox 1.0.
    By default this is set to Microsoft Internet Explorer provided by ##### or Mozilla Firefox .
    Here's how to change that..... For Internet Explorer (6) Warning! Changing the title
    for internet explorer requires editing the registry. Making changes in the registry in keys or
    values that are not listed here could cause your computer to crash or slow. Follow the fo....
  8. Php Sockets
    Introduction to an underused function of PHP (4)
    This tutorial is based on a question written in the PHP programming board Inspiration
    Introduction Sockets, an underused function in PHP, is a function that enables you to open
    connection to other peoples computers and vice versa. By sending commands to the operating server,
    it will first see if there's response, then, it sends or receives data that the operating server
    has available. Creation of a socket Of course, a first step in using sockets, is creating it,
    this is done by: CODE resource socket_create ( int domain, int type, int protocol) ....
  9. Getting Started In Vb 6
    Printing out Hello World! in a text box. (0)
    Sorry for a duplicate post in Programming::VB Programming, I accidentally submitted this topic when
    I wasn't done. This example prints out Hello World! First launch VB 6. Second on the
    dialog that pops up create a New Standard Project and click Open. You should see this so far:
    Now click the A button in the toolbox to the left: Click the drag the object. Now click AB| next
    to the A in the toolbox. Drag it under Label1. Then click the button under the AB| and drag it under
    Text1. It should now look like this: Now that we have done adding objects ....
  10. Simple Parsing Functions
    [Delphi] Tutorial (0)
    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 components (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 ....
  11. Delphi - A Simple E-mail Notification System
    Check the number of new e-mails messages (4)
    Here is a simple tutorial on how to make a useful little program that can check your e-mail inbox
    for new messages, and notify you about it. If you save the finished EXE file on your hard disk, you
    can also configure windows to start it automatically when windows is loaded, and get notified when
    your inbox is checked for new messages. Here is a checklist on what you need: -Borland Delphi
    -Installed Indy components (these are automatically installed if you are using Delphi 6 or Delphi 7)
    Onward! Create a new project in Delphi. Select the Indy “IdPop3” component f....
  12. Using The Date() Function [php]
    (2)
    The date() function can be used in a good way, in some cases, and the most common place you would
    probably see this in use would be on forums. Let's get down to business... If you would like to
    display the date, you would have to put the echo tag before the date() function as so... CODE
    echo date("g:i:s"); Which would display as the common hours, minutes,
    seconds format (ex: 3:32:45). But you can also add wheather it is AM or PM, display the day (Sunday
    thru Monday), the year, pretty much anything that has to do with date. Here is a....
  13. Delphi Tutorial - Change Your Start Button Caption
    (4)
    How to change your start button caption using Delphi! (By the way, the start button will be
    renamed back to "start" after you restart your computer) Here we go! 1. Create a new project
    in Delphi 2. Add a Button and an Edit box to your form, place them where you want. 3. Double click
    the button to enter the code editor so we can type code for our OnClick event. 4. The code for the
    OnClick event of our button should look like this: CODE procedure
    TForm1.Button1Click(Sender: TObject); var Handle1,Handle2:hwnd; begin
    Handle1:=FindWindo....
  14. [tutorial] Delphi
    Multi-Parsing Function (0)
    I've spent a while trying to create parsing function with Delphi. This language is very useful.
    This tutorial explains how to parse multiple instances of an item in one string. Here is the
    function (which I am actually very proud of): Code: function TForm1.MultiParse(MainString,
    BeginString, EndString: string): TStrings; var PosBeginString, PosEndString, i, LastPos: integer;
    tmpCopy: string; tmpStrings: TStrings; begin tmpStrings := TStringList.Create; LastPos := 0;
    for i := 1 to LastDelimiter(EndString, MainString) do begin PosBeginString := Pos....

    1. Looking for delphi, simple, text, parsing, function

Searching Video's for delphi, simple, text, parsing, function
advertisement



Delphi - Simple Text Parsing Function



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE