Click here to Skip to main content
15,925,400 members
Home / Discussions / C#
   

C#

 
GeneralRe: Regular Expression to convert from PHP to C# [modified] Pin
User 665825-Jun-06 11:52
User 665825-Jun-06 11:52 
GeneralRe: Regular Expression to convert from PHP to C# Pin
AngryC25-Jun-06 12:23
AngryC25-Jun-06 12:23 
GeneralRe: Regular Expression to convert from PHP to C# Pin
Graham Nimbley25-Jun-06 13:36
Graham Nimbley25-Jun-06 13:36 
This should be it.

string regex=@"(.+)\#(.+)\r\n";
string replace=String.Format("{0}$1{1}$2{2}\r\n","Left","Center","Right");

string output=Regex.Replace(input,regex,replace);


I've tweaked the regex as I was having problem with it.

I've dumped the code I used to test it:

using System;
using System.Text.RegularExpressions;

public class Testy
{
	public static void Main()
	{
	
string input="bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.\r\n\r\n"+
"toto toto toto # toto toto toto\r\n"+
"toto toto toto # toto toto toto\r\n"+
"toto toto toto # toto toto toto\r\n"+
"toto toto toto # toto toto toto\r\n\r\n"+
"bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla";

		string regex=@"(.+)\#(.+)\r\n";
		string replace=String.Format("{0}$1{1}$2{2}\r\n","Left","Center","Right");

		string output=Regex.Replace(input,regex,replace);
		
		Console.WriteLine(output);
	}
}

GeneralRe: Regular Expression to convert from PHP to C# Pin
AngryC25-Jun-06 15:05
AngryC25-Jun-06 15:05 
GeneralRe: Regular Expression to convert from PHP to C# Pin
Graham Nimbley25-Jun-06 15:10
Graham Nimbley25-Jun-06 15:10 
GeneralRe: Regular Expression to convert from PHP to C# Pin
AngryC25-Jun-06 16:51
AngryC25-Jun-06 16:51 
GeneralRe: Regular Expression to convert from PHP to C# [modified] Pin
Graham Nimbley26-Jun-06 8:39
Graham Nimbley26-Jun-06 8:39 
GeneralRe: Regular Expression to convert from PHP to C# [modified] Pin
AngryC26-Jun-06 11:29
AngryC26-Jun-06 11:29 
GeneralRe: Regular Expression to convert from PHP to C# [modified] Pin
Graham Nimbley26-Jun-06 11:56
Graham Nimbley26-Jun-06 11:56 
GeneralRe: Regular Expression to convert from PHP to C# Pin
AngryC26-Jun-06 12:34
AngryC26-Jun-06 12:34 
GeneralRe: Regular Expression to convert from PHP to C# [modified] Pin
Graham Nimbley26-Jun-06 13:05
Graham Nimbley26-Jun-06 13:05 
GeneralRe: Regular Expression to convert from PHP to C# [modified] Pin
AngryC26-Jun-06 13:16
AngryC26-Jun-06 13:16 
GeneralRe: Regular Expression to convert from PHP to C# Pin
Graham Nimbley26-Jun-06 13:21
Graham Nimbley26-Jun-06 13:21 
GeneralRe: Regular Expression to convert from PHP to C# Pin
AngryC26-Jun-06 13:30
AngryC26-Jun-06 13:30 
GeneralRe: Regular Expression to convert from PHP to C# Pin
Graham Nimbley26-Jun-06 13:41
Graham Nimbley26-Jun-06 13:41 
QuestionDeserialize XML by reverse-engineering class def Pin
Ed 5425-Jun-06 5:18
Ed 5425-Jun-06 5:18 
AnswerRe: Deserialize XML by reverse-engineering class def Pin
Guffa25-Jun-06 6:35
Guffa25-Jun-06 6:35 
GeneralRe: Deserialize XML by reverse-engineering class def Pin
Ed 5425-Jun-06 16:48
Ed 5425-Jun-06 16:48 
AnswerRe: Deserialize XML by reverse-engineering class def Pin
Guffa25-Jun-06 18:52
Guffa25-Jun-06 18:52 
GeneralRe: Deserialize XML by reverse-engineering class def Pin
Ed 5426-Jun-06 12:57
Ed 5426-Jun-06 12:57 
QuestionUnderstanding DataSets... [modified] Pin
martin_hughes25-Jun-06 4:56
martin_hughes25-Jun-06 4:56 
AnswerRe: Understanding DataSets... Pin
Robert Rohde25-Jun-06 20:10
Robert Rohde25-Jun-06 20:10 
QuestionOptional field selection SQL Pin
WillemM25-Jun-06 4:30
WillemM25-Jun-06 4:30 
AnswerRe: Optional field selection SQL Pin
Michael P Butler25-Jun-06 5:04
Michael P Butler25-Jun-06 5:04 
GeneralRe: Optional field selection SQL Pin
WillemM25-Jun-06 5:28
WillemM25-Jun-06 5:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.