WeixiangYan/CodeTransOcean huggingface dataset:
Task: Trigonometric functions

C: #include <math.h>
#include <stdio.h>

int main() {
  double pi = 4 * atan(1);
  
  double radians = pi / 4;
  double degrees = 45.0;
  double temp;
  
  printf("%f %f\n", sin(radians), sin(degrees * pi / 180));
  
  printf("%f %f\n", cos(radians), cos(degrees * pi / 180));
  
  printf("%f %f\n", tan(radians), tan(degrees * pi / 180));
  
  temp = asin(sin(radians));
  printf("%f %f\n", temp, temp * 180 / pi);
  
  temp = acos(cos(radians));
  printf("%f %f\n", temp, temp * 180 / pi);
  
  temp = atan(tan(radians));
  printf("%f %f\n", temp, temp * 180 / pi);

  return 0;
}








VB: Public Sub trig()
    Pi = WorksheetFunction.Pi()
    Debug.Print Sin(Pi / 2)
    Debug.Print Sin(90 * Pi / 180)
    Debug.Print Cos(0)
    Debug.Print Cos(0 * Pi / 180)
    Debug.Print Tan(Pi / 4)
    Debug.Print Tan(45 * Pi / 180)
    Debug.Print WorksheetFunction.Asin(1) * 2
    Debug.Print WorksheetFunction.Asin(1) * 180 / Pi
    Debug.Print WorksheetFunction.Acos(0) * 2
    Debug.Print WorksheetFunction.Acos(0) * 180 / Pi
    Debug.Print Atn(1) * 4
    Debug.Print Atn(1) * 180 / Pi
End Sub
Task: Trigonometric functions



C#: using System;

namespace RosettaCode {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine("=== radians ===");
            Console.WriteLine("sin (pi/3) = {0}", Math.Sin(Math.PI / 3));
            Console.WriteLine("cos (pi/3) = {0}", Math.Cos(Math.PI / 3));
            Console.WriteLine("tan (pi/3) = {0}", Math.Tan(Math.PI / 3));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5));
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5));
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5));
            Console.WriteLine("");
            Console.WriteLine("=== degrees ===");
            Console.WriteLine("sin (60) = {0}", Math.Sin(60 * Math.PI / 180));
            Console.WriteLine("cos (60) = {0}", Math.Cos(60 * Math.PI / 180));
            Console.WriteLine("tan (60) = {0}", Math.Tan(60 * Math.PI / 180));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5) * 180/ Math.PI);
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5) * 180 / Math.PI);
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5) * 180 / Math.PI);

            Console.ReadLine();
        }
    }
}



Java: public class Trig {
        public static void main(String[] args) {
                
                double radians = Math.PI / 4;
                double degrees = 45.0;
                
                System.out.println(Math.sin(radians) + " " + Math.sin(Math.toRadians(degrees)));
                
                System.out.println(Math.cos(radians) + " " + Math.cos(Math.toRadians(degrees)));
                
                System.out.println(Math.tan(radians) + " " + Math.tan(Math.toRadians(degrees)));
                
                double arcsin = Math.asin(Math.sin(radians));
                System.out.println(arcsin + " " + Math.toDegrees(arcsin));
                
                double arccos = Math.acos(Math.cos(radians));
                System.out.println(arccos + " " + Math.toDegrees(arccos));
                
                double arctan = Math.atan(Math.tan(radians));
                System.out.println(arctan + " " + Math.toDegrees(arctan));
        }
}
Task: Trigonometric functions

C: #include <math.h>
#include <stdio.h>

int main() {
  double pi = 4 * atan(1);
  
  double radians = pi / 4;
  double degrees = 45.0;
  double temp;
  
  printf("%f %f\n", sin(radians), sin(degrees * pi / 180));
  
  printf("%f %f\n", cos(radians), cos(degrees * pi / 180));
  
  printf("%f %f\n", tan(radians), tan(degrees * pi / 180));
  
  temp = asin(sin(radians));
  printf("%f %f\n", temp, temp * 180 / pi);
  
  temp = acos(cos(radians));
  printf("%f %f\n", temp, temp * 180 / pi);
  
  temp = atan(tan(radians));
  printf("%f %f\n", temp, temp * 180 / pi);

  return 0;
}




Go: package main

import (
    "fmt"
    "math"
)

const d = 30.
const r = d * math.Pi / 180

var s = .5
var c = math.Sqrt(3) / 2
var t = 1 / math.Sqrt(3)

func main() {
    fmt.Printf("sin(%9.6f deg) = %f\n", d, math.Sin(d*math.Pi/180))
    fmt.Printf("sin(%9.6f rad) = %f\n", r, math.Sin(r))
    fmt.Printf("cos(%9.6f deg) = %f\n", d, math.Cos(d*math.Pi/180))
    fmt.Printf("cos(%9.6f rad) = %f\n", r, math.Cos(r))
    fmt.Printf("tan(%9.6f deg) = %f\n", d, math.Tan(d*math.Pi/180))
    fmt.Printf("tan(%9.6f rad) = %f\n", r, math.Tan(r))
    fmt.Printf("asin(%f) = %9.6f deg\n", s, math.Asin(s)*180/math.Pi)
    fmt.Printf("asin(%f) = %9.6f rad\n", s, math.Asin(s))
    fmt.Printf("acos(%f) = %9.6f deg\n", c, math.Acos(c)*180/math.Pi)
    fmt.Printf("acos(%f) = %9.6f rad\n", c, math.Acos(c))
    fmt.Printf("atan(%f) = %9.6f deg\n", t, math.Atan(t)*180/math.Pi)
    fmt.Printf("atan(%f) = %9.6f rad\n", t, math.Atan(t))
}
Task: Trigonometric functions

C: #include <math.h>
#include <stdio.h>

int main() {
  double pi = 4 * atan(1);
  
  double radians = pi / 4;
  double degrees = 45.0;
  double temp;
  
  printf("%f %f\n", sin(radians), sin(degrees * pi / 180));
  
  printf("%f %f\n", cos(radians), cos(degrees * pi / 180));
  
  printf("%f %f\n", tan(radians), tan(degrees * pi / 180));
  
  temp = asin(sin(radians));
  printf("%f %f\n", temp, temp * 180 / pi);
  
  temp = acos(cos(radians));
  printf("%f %f\n", temp, temp * 180 / pi);
  
  temp = atan(tan(radians));
  printf("%f %f\n", temp, temp * 180 / pi);

  return 0;
}






PHP: $radians = M_PI / 4;
$degrees = 45 * M_PI / 180;
echo sin($radians) . " " . sin($degrees);
echo cos($radians) . " " . cos($degrees);
echo tan($radians) . " " . tan($degrees);
echo asin(sin($radians)) . " " . asin(sin($radians)) * 180 / M_PI;
echo acos(cos($radians)) . " " . acos(cos($radians)) * 180 / M_PI;
echo atan(tan($radians)) . " " . atan(tan($radians)) * 180 / M_PI;
Task: Trigonometric functions



C#: using System;

namespace RosettaCode {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine("=== radians ===");
            Console.WriteLine("sin (pi/3) = {0}", Math.Sin(Math.PI / 3));
            Console.WriteLine("cos (pi/3) = {0}", Math.Cos(Math.PI / 3));
            Console.WriteLine("tan (pi/3) = {0}", Math.Tan(Math.PI / 3));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5));
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5));
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5));
            Console.WriteLine("");
            Console.WriteLine("=== degrees ===");
            Console.WriteLine("sin (60) = {0}", Math.Sin(60 * Math.PI / 180));
            Console.WriteLine("cos (60) = {0}", Math.Cos(60 * Math.PI / 180));
            Console.WriteLine("tan (60) = {0}", Math.Tan(60 * Math.PI / 180));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5) * 180/ Math.PI);
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5) * 180 / Math.PI);
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5) * 180 / Math.PI);

            Console.ReadLine();
        }
    }
}




PHP: $radians = M_PI / 4;
$degrees = 45 * M_PI / 180;
echo sin($radians) . " " . sin($degrees);
echo cos($radians) . " " . cos($degrees);
echo tan($radians) . " " . tan($degrees);
echo asin(sin($radians)) . " " . asin(sin($radians)) * 180 / M_PI;
echo acos(cos($radians)) . " " . acos(cos($radians)) * 180 / M_PI;
echo atan(tan($radians)) . " " . atan(tan($radians)) * 180 / M_PI;
Task: Trigonometric functions


C++: #include <iostream>
#include <cmath>

#ifdef M_PI 
double const pi = M_PI;
#else
double const pi = 4*std::atan(1);
#endif

double const degree = pi/180;

int main()
{
  std::cout << "=== radians ===\n";
  std::cout << "sin(pi/3) = " << std::sin(pi/3) << "\n";
  std::cout << "cos(pi/3) = " << std::cos(pi/3) << "\n";
  std::cout << "tan(pi/3) = " << std::tan(pi/3) << "\n";
  std::cout << "arcsin(1/2) = " << std::asin(0.5) << "\n";
  std::cout << "arccos(1/2) = " << std::acos(0.5) << "\n";
  std::cout << "arctan(1/2) = " << std::atan(0.5) << "\n";

  std::cout << "\n=== degrees ===\n";
  std::cout << "sin(60°) = " << std::sin(60*degree) << "\n";
  std::cout << "cos(60°) = " << std::cos(60*degree) << "\n";
  std::cout << "tan(60°) = " << std::tan(60*degree) << "\n";
  std::cout << "arcsin(1/2) = " << std::asin(0.5)/degree << "°\n";
  std::cout << "arccos(1/2) = " << std::acos(0.5)/degree << "°\n";
  std::cout << "arctan(1/2) = " << std::atan(0.5)/degree << "°\n";

  return 0;
}





PHP: $radians = M_PI / 4;
$degrees = 45 * M_PI / 180;
echo sin($radians) . " " . sin($degrees);
echo cos($radians) . " " . cos($degrees);
echo tan($radians) . " " . tan($degrees);
echo asin(sin($radians)) . " " . asin(sin($radians)) * 180 / M_PI;
echo acos(cos($radians)) . " " . acos(cos($radians)) * 180 / M_PI;
echo atan(tan($radians)) . " " . atan(tan($radians)) * 180 / M_PI;
Task: Trigonometric functions




Go: package main

import (
    "fmt"
    "math"
)

const d = 30.
const r = d * math.Pi / 180

var s = .5
var c = math.Sqrt(3) / 2
var t = 1 / math.Sqrt(3)

func main() {
    fmt.Printf("sin(%9.6f deg) = %f\n", d, math.Sin(d*math.Pi/180))
    fmt.Printf("sin(%9.6f rad) = %f\n", r, math.Sin(r))
    fmt.Printf("cos(%9.6f deg) = %f\n", d, math.Cos(d*math.Pi/180))
    fmt.Printf("cos(%9.6f rad) = %f\n", r, math.Cos(r))
    fmt.Printf("tan(%9.6f deg) = %f\n", d, math.Tan(d*math.Pi/180))
    fmt.Printf("tan(%9.6f rad) = %f\n", r, math.Tan(r))
    fmt.Printf("asin(%f) = %9.6f deg\n", s, math.Asin(s)*180/math.Pi)
    fmt.Printf("asin(%f) = %9.6f rad\n", s, math.Asin(s))
    fmt.Printf("acos(%f) = %9.6f deg\n", c, math.Acos(c)*180/math.Pi)
    fmt.Printf("acos(%f) = %9.6f rad\n", c, math.Acos(c))
    fmt.Printf("atan(%f) = %9.6f deg\n", t, math.Atan(t)*180/math.Pi)
    fmt.Printf("atan(%f) = %9.6f rad\n", t, math.Atan(t))
}



PHP: $radians = M_PI / 4;
$degrees = 45 * M_PI / 180;
echo sin($radians) . " " . sin($degrees);
echo cos($radians) . " " . cos($degrees);
echo tan($radians) . " " . tan($degrees);
echo asin(sin($radians)) . " " . asin(sin($radians)) * 180 / M_PI;
echo acos(cos($radians)) . " " . acos(cos($radians)) * 180 / M_PI;
echo atan(tan($radians)) . " " . atan(tan($radians)) * 180 / M_PI;
Task: Trigonometric functions





Java: public class Trig {
        public static void main(String[] args) {
                
                double radians = Math.PI / 4;
                double degrees = 45.0;
                
                System.out.println(Math.sin(radians) + " " + Math.sin(Math.toRadians(degrees)));
                
                System.out.println(Math.cos(radians) + " " + Math.cos(Math.toRadians(degrees)));
                
                System.out.println(Math.tan(radians) + " " + Math.tan(Math.toRadians(degrees)));
                
                double arcsin = Math.asin(Math.sin(radians));
                System.out.println(arcsin + " " + Math.toDegrees(arcsin));
                
                double arccos = Math.acos(Math.cos(radians));
                System.out.println(arccos + " " + Math.toDegrees(arccos));
                
                double arctan = Math.atan(Math.tan(radians));
                System.out.println(arctan + " " + Math.toDegrees(arctan));
        }
}


PHP: $radians = M_PI / 4;
$degrees = 45 * M_PI / 180;
echo sin($radians) . " " . sin($degrees);
echo cos($radians) . " " . cos($degrees);
echo tan($radians) . " " . tan($degrees);
echo asin(sin($radians)) . " " . asin(sin($radians)) * 180 / M_PI;
echo acos(cos($radians)) . " " . acos(cos($radians)) * 180 / M_PI;
echo atan(tan($radians)) . " " . atan(tan($radians)) * 180 / M_PI;
Task: Trigonometric functions






PHP: $radians = M_PI / 4;
$degrees = 45 * M_PI / 180;
echo sin($radians) . " " . sin($degrees);
echo cos($radians) . " " . cos($degrees);
echo tan($radians) . " " . tan($degrees);
echo asin(sin($radians)) . " " . asin(sin($radians)) * 180 / M_PI;
echo acos(cos($radians)) . " " . acos(cos($radians)) * 180 / M_PI;
echo atan(tan($radians)) . " " . atan(tan($radians)) * 180 / M_PI;


Python: Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from math import degrees, radians, sin, cos, tan, asin, acos, atan, pi
>>> rad, deg = pi/4, 45.0
>>> print("Sine:", sin(rad), sin(radians(deg)))
Sine: 0.7071067811865475 0.7071067811865475
>>> print("Cosine:", cos(rad), cos(radians(deg)))
Cosine: 0.7071067811865476 0.7071067811865476
>>> print("Tangent:", tan(rad), tan(radians(deg)))
Tangent: 0.9999999999999999 0.9999999999999999
>>> arcsine = asin(sin(rad))
>>> print("Arcsine:", arcsine, degrees(arcsine))
Arcsine: 0.7853981633974482 44.99999999999999
>>> arccosine = acos(cos(rad))
>>> print("Arccosine:", arccosine, degrees(arccosine))
Arccosine: 0.7853981633974483 45.0
>>> arctangent = atan(tan(rad))
>>> print("Arctangent:", arctangent, degrees(arctangent))
Arctangent: 0.7853981633974483 45.0
>>>
Task: Trigonometric functions






PHP: $radians = M_PI / 4;
$degrees = 45 * M_PI / 180;
echo sin($radians) . " " . sin($degrees);
echo cos($radians) . " " . cos($degrees);
echo tan($radians) . " " . tan($degrees);
echo asin(sin($radians)) . " " . asin(sin($radians)) * 180 / M_PI;
echo acos(cos($radians)) . " " . acos(cos($radians)) * 180 / M_PI;
echo atan(tan($radians)) . " " . atan(tan($radians)) * 180 / M_PI;



VB: Public Sub trig()
    Pi = WorksheetFunction.Pi()
    Debug.Print Sin(Pi / 2)
    Debug.Print Sin(90 * Pi / 180)
    Debug.Print Cos(0)
    Debug.Print Cos(0 * Pi / 180)
    Debug.Print Tan(Pi / 4)
    Debug.Print Tan(45 * Pi / 180)
    Debug.Print WorksheetFunction.Asin(1) * 2
    Debug.Print WorksheetFunction.Asin(1) * 180 / Pi
    Debug.Print WorksheetFunction.Acos(0) * 2
    Debug.Print WorksheetFunction.Acos(0) * 180 / Pi
    Debug.Print Atn(1) * 4
    Debug.Print Atn(1) * 180 / Pi
End Sub
Task: Text between

C: 
char* textBetween(char* thisText, char* startText, char* endText, char* returnText)
{
	

    char* startPointer = NULL;
    int stringLength = 0;

    char* endPointer = NULL;
    int endLength = 0;

	if (strstr(startText, "start") != NULL)
	{
		
		startPointer = thisText;
	} else {
		startPointer = strstr(thisText, startText);

    	if (startPointer != NULL)
	    {
        	startPointer = startPointer + strlen(startText);
        }
	} 
    
    if (startPointer != NULL)
    {

		if (strstr(endText, "end") != NULL)
		{
			
			endPointer = thisText;
			endLength = 0;
		} else {
			endPointer = strstr(startPointer, endText);
			endLength = (int)strlen(endPointer);
		} 

        stringLength = strlen(startPointer) - endLength;
        
        if (stringLength == 0)
        {
		    returnText = "";
		    startPointer = NULL;
        } else {
	        
    	    strncpy(returnText,startPointer, stringLength);
	        returnText[stringLength++] = '\0';
		}
        
    } else {
	    
	    returnText = "";
	    
    } 
    
    return startPointer;
} 



C#: #include <iostream>

std::ostream& operator<<(std::ostream& out, const std::string& str) {
    return out << str.c_str();
}

std::string textBetween(const std::string& source, const std::string& beg, const std::string& end) {
    size_t startIndex;
    if (beg == "start") {
        startIndex = 0;
    } else {
        startIndex = source.find(beg);
        if (startIndex == std::string::npos) {
            return "";
        }
        startIndex += beg.length();
    }

    size_t endIndex = source.find(end, startIndex);
    if (endIndex == std::string::npos || end == "end") {
        return source.substr(startIndex);
    }

    return source.substr(startIndex, endIndex - startIndex);
}

void print(const std::string& source, const std::string& beg, const std::string& end) {
    using namespace std;
    cout << "text: '" << source << "'\n";
    cout << "start: '" << beg << "'\n";
    cout << "end: '" << end << "'\n";
    cout << "result: '" << textBetween(source, beg, end) << "'\n";
    cout << '\n';
}

int main() {
    print("Hello Rosetta Code world", "Hello ", " world");
    print("Hello Rosetta Code world", "start", " world");
    print("Hello Rosetta Code world", "Hello ", "end");
    print("<text>Hello <span>Rosetta Code</span> world</text><table style=\"myTable\">", "<text>", "<table>");
    print("<table style=\"myTable\"><tr><td>hello world</td></tr></table>", "<table>", "</table>");
    print("The quick brown fox jumps over the lazy other fox", "quick ", " fox");
    print("One fish two fish red fish blue fish", "fish ", " red");
    print("FooBarBazFooBuxQuux", "Foo", "Foo");

    return 0;
}
Task: Text between

C: 
char* textBetween(char* thisText, char* startText, char* endText, char* returnText)
{
	

    char* startPointer = NULL;
    int stringLength = 0;

    char* endPointer = NULL;
    int endLength = 0;

	if (strstr(startText, "start") != NULL)
	{
		
		startPointer = thisText;
	} else {
		startPointer = strstr(thisText, startText);

    	if (startPointer != NULL)
	    {
        	startPointer = startPointer + strlen(startText);
        }
	} 
    
    if (startPointer != NULL)
    {

		if (strstr(endText, "end") != NULL)
		{
			
			endPointer = thisText;
			endLength = 0;
		} else {
			endPointer = strstr(startPointer, endText);
			endLength = (int)strlen(endPointer);
		} 

        stringLength = strlen(startPointer) - endLength;
        
        if (stringLength == 0)
        {
		    returnText = "";
		    startPointer = NULL;
        } else {
	        
    	    strncpy(returnText,startPointer, stringLength);
	        returnText[stringLength++] = '\0';
		}
        
    } else {
	    
	    returnText = "";
	    
    } 
    
    return startPointer;
} 







Python: 
from sys import argv






def textBetween( thisText, startString, endString ):
    try:
    	if startString is 'start':
    		startIndex = 0
    	else:
    		startIndex = thisText.index( startString ) 
    	
    	if not (startIndex >= 0):
    		return 'Start delimiter not found'
    	else:
        	if startString is not 'start':
        		startIndex = startIndex + len( startString )
        
        returnText = thisText[startIndex:]


    	if endString is 'end':
    		return returnText
    	else:
    		endIndex = returnText.index( endString )

    	if not (endIndex >= 0):
    		return 'End delimiter not found'
    	else:
        	returnText = returnText[:endIndex]

        return returnText
    except ValueError:
        return "Value error"

script, first, second, third = argv

thisText = first
startString = second
endString = third

print textBetween( thisText, startString, endString )
Task: Text between


C++: #include <iostream>

std::ostream& operator<<(std::ostream& out, const std::string& str) {
    return out << str.c_str();
}

std::string textBetween(const std::string& source, const std::string& beg, const std::string& end) {
    size_t startIndex;
    if (beg == "start") {
        startIndex = 0;
    } else {
        startIndex = source.find(beg);
        if (startIndex == std::string::npos) {
            return "";
        }
        startIndex += beg.length();
    }

    size_t endIndex = source.find(end, startIndex);
    if (endIndex == std::string::npos || end == "end") {
        return source.substr(startIndex);
    }

    return source.substr(startIndex, endIndex - startIndex);
}

void print(const std::string& source, const std::string& beg, const std::string& end) {
    using namespace std;
    cout << "text: '" << source << "'\n";
    cout << "start: '" << beg << "'\n";
    cout << "end: '" << end << "'\n";
    cout << "result: '" << textBetween(source, beg, end) << "'\n";
    cout << '\n';
}

int main() {
    print("Hello Rosetta Code world", "Hello ", " world");
    print("Hello Rosetta Code world", "start", " world");
    print("Hello Rosetta Code world", "Hello ", "end");
    print("<text>Hello <span>Rosetta Code</span> world</text><table style=\"myTable\">", "<text>", "<table>");
    print("<table style=\"myTable\"><tr><td>hello world</td></tr></table>", "<table>", "</table>");
    print("The quick brown fox jumps over the lazy other fox", "quick ", " fox");
    print("One fish two fish red fish blue fish", "fish ", " red");
    print("FooBarBazFooBuxQuux", "Foo", "Foo");

    return 0;
}




Java: public class textBetween
{
    
    static String textBetween(String thisText, String startString, String endString)
    {
    	String returnText = "";
    	int startIndex = 0;
    	int endIndex = 0;
    	
    	if (startString.equals("start"))
    	{
    		startIndex = 0;
    	} else {
	    	startIndex = thisText.indexOf(startString);
	    	
	    	if (startIndex < 0) 
	        {
	        	return "";	        	
	        } else {
	        	startIndex = startIndex + startString.length();
	        }
    	}
        
    	if (endString.equals("end"))
    	{
    		endIndex = thisText.length();
    	} else {
    		endIndex = thisText.indexOf(endString);
            
            if (endIndex <= 0) 
            {
            	return "";
            } else {

            }	
    	}
    	
    	returnText = thisText.substring(startIndex,endIndex);
    	
    	return returnText;
    } 

    
    public static void main(String[] args)
    {
    	String thisText = args[0];
    	String startDelimiter = args[1];
    	String endDelimiter = args[2];
    	
    	String returnText = "";
    	returnText = textBetween(thisText, startDelimiter, endDelimiter);
    	
        System.out.println(returnText);

    } 
    
}
Task: Text between


C++: #include <iostream>

std::ostream& operator<<(std::ostream& out, const std::string& str) {
    return out << str.c_str();
}

std::string textBetween(const std::string& source, const std::string& beg, const std::string& end) {
    size_t startIndex;
    if (beg == "start") {
        startIndex = 0;
    } else {
        startIndex = source.find(beg);
        if (startIndex == std::string::npos) {
            return "";
        }
        startIndex += beg.length();
    }

    size_t endIndex = source.find(end, startIndex);
    if (endIndex == std::string::npos || end == "end") {
        return source.substr(startIndex);
    }

    return source.substr(startIndex, endIndex - startIndex);
}

void print(const std::string& source, const std::string& beg, const std::string& end) {
    using namespace std;
    cout << "text: '" << source << "'\n";
    cout << "start: '" << beg << "'\n";
    cout << "end: '" << end << "'\n";
    cout << "result: '" << textBetween(source, beg, end) << "'\n";
    cout << '\n';
}

int main() {
    print("Hello Rosetta Code world", "Hello ", " world");
    print("Hello Rosetta Code world", "start", " world");
    print("Hello Rosetta Code world", "Hello ", "end");
    print("<text>Hello <span>Rosetta Code</span> world</text><table style=\"myTable\">", "<text>", "<table>");
    print("<table style=\"myTable\"><tr><td>hello world</td></tr></table>", "<table>", "</table>");
    print("The quick brown fox jumps over the lazy other fox", "quick ", " fox");
    print("One fish two fish red fish blue fish", "fish ", " red");
    print("FooBarBazFooBuxQuux", "Foo", "Foo");

    return 0;
}






Python: 
from sys import argv






def textBetween( thisText, startString, endString ):
    try:
    	if startString is 'start':
    		startIndex = 0
    	else:
    		startIndex = thisText.index( startString ) 
    	
    	if not (startIndex >= 0):
    		return 'Start delimiter not found'
    	else:
        	if startString is not 'start':
        		startIndex = startIndex + len( startString )
        
        returnText = thisText[startIndex:]


    	if endString is 'end':
    		return returnText
    	else:
    		endIndex = returnText.index( endString )

    	if not (endIndex >= 0):
    		return 'End delimiter not found'
    	else:
        	returnText = returnText[:endIndex]

        return returnText
    except ValueError:
        return "Value error"

script, first, second, third = argv

thisText = first
startString = second
endString = third

print textBetween( thisText, startString, endString )