PHP regular expresion function to vb.net or C#?

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
dhernando2
Forum Newbie
Posts: 1
Joined: Sat Jul 10, 2010 7:58 pm

PHP regular expresion function to vb.net or C#?

Post by dhernando2 »

Hi Guys,

This is my first post and I need some help :-\

I want to post this to see if anyone can help me, I need to convert a php function into vb.net or C# but I have no idea, here's the function:

Code: Select all

echo spin('{an {option|choice|right}|the basic} element {more|another|else}');

function spin($s){
	preg_match('#\{(.+?)\}#is',$s,$m);
	if(empty($m)) return $s;
	
	$t = $m[1];
	
	if(strpos($t,'{')!==false){
		$t = substr($t, strrpos($t,'{') + 1);
	}
	
	$parts = explode("|", $t);
	$s = preg_replace("+\{".preg_quote($t)."\}+is", $parts[array_rand($parts)], $s, 1);
	
	return spin($s);
}
I don't mind to move the question to a type of project(to paid you) if you know the answer.

Thanks,

Diego
Post Reply