A very handy function when you are processing URLs and/or HTTP response.

Function call


Action()
{
//example URL
lr_save_string("https://mail.google.com/mail/?hl=en&tab=wm#inbox", "InputName");

lr_output_message("String before processing = \"%s\"",
				  lr_eval_string("{InputName}"));

strLastOccr(lr_eval_string("{InputName}"), "OutputProjName", "/");

lr_output_message("Portion of the string after last occurance of forward-slash= %s",
				  lr_eval_string("{OutputProjName}"));
return 0;
}


Function description


void strLastOccr(char inputStr[100], char* outputStr, char *delim)
{

	char value[100],*temp, *temp2;
	int i = 0;

	temp = "";
	while (temp!=NULL)
	{

		if(i==0)
		{
			temp2 = temp;
			temp = (char *)strtok(inputStr,delim);
			i++;

		}

		if(i>0)
		{
			temp2 = temp;
			temp = (char *)strtok(NULL,delim);

		}

		lr_save_string(temp2,outputStr);

	}
}


Output


Starting iteration 1.
Starting action Action.
Action.c(7): String before processing = "https://mail.google.com/mail/?hl=en&tab=wm#inbox"
Action.c(13): Portion of the string after last occurance of forward-slash= "?hl=en&tab=wm#inbox"
Ending action Action.
Ending iteration 1.