Adblock breaks this site

GetBetween (get between two strings!)

Discussion in 'Programming General' started by Blupig, Nov 29, 2011.

  1. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant
    GetBetween (get between two strings!)

    I use this function way too often in VB, C#, etc, whenever I'm parsing, and to my dismay I found nothing like it on Google, so I made my own.

    Voila:

    Code:
    string getBetween(string fullstring, string start, string end)
    {
    	int spos = fullstring.find(start) + start.length();
    	int epos = fullstring.find(end);
    
    	int length = (epos - spos);
    
    	return fullstring.substr(spos, length);
    }
    
    Uses the <string> header
     
  2. iJava

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441
    GetBetween (get between two strings!)

    Nice work, so you're moving away from .Net languages?
     
  3. Govind

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus
    GetBetween (get between two strings!)

    There is C++ for .NET, lol.
     
  4. iJava

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441
    GetBetween (get between two strings!)

    Yeah but I thought that one of the main reasons people used C++ over C# or VB.Net was because of dependencies?
     
  5. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant
    GetBetween (get between two strings!)

    Nope, I'll still use VB/C# over C++ any day. I hate C++. Just need it for my program at uni :p
     
< Tutorial On Boolean's | Flash game programing >


 
 
Adblock breaks this site