RegEx help
-
Hi Gurus, I am using RegEx class for parsing some strings of the following format
[Hello World message 234...]
What is the expression that I need to use to format the above string?? Thanks...
Sunil
What do you mean by "formatting the above string"?? Are you looking to pull information out of the string?? What would that data be??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
What do you mean by "formatting the above string"?? Are you looking to pull information out of the string?? What would that data be??
A guide to posting questions on CodeProject[^]
Dave KreskowiakHi Dave, This is my requirement. I read a line from a file, which is in the following format: [Some message 123...] So I would want to create a RegEx pattern for the above format. What would be the expression for this case. I tried this but it failed while calling method RegEx.Match():
RegEx _exp = new Regex(@"^\[(?\w+)]", RegexOptions.IgnoreCase);
Sunil
-
Hi Gurus, I am using RegEx class for parsing some strings of the following format
[Hello World message 234...]
What is the expression that I need to use to format the above string?? Thanks...
Sunil
Why are you using a RegEx when you can easily separate the tokens of the message with the
String.Split()
[^] method? Perhaps if you explain exactly what you are trying to do we can make some more informed suggestions.Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
Hi Dave, This is my requirement. I read a line from a file, which is in the following format: [Some message 123...] So I would want to create a RegEx pattern for the above format. What would be the expression for this case. I tried this but it failed while calling method RegEx.Match():
RegEx _exp = new Regex(@"^\[(?\w+)]", RegexOptions.IgnoreCase);
Sunil
That still doesn't help. Why do you need a regex, what problem is it supposed to solve?
-
Hi Gurus, I am using RegEx class for parsing some strings of the following format
[Hello World message 234...]
What is the expression that I need to use to format the above string?? Thanks...
Sunil
There is a Regular Expression forum. Perhaps you should provide more examples and the results you want. If you want to separate the message part from the number part, perhaps something like this might help:
@"(?'message'[^\d]*)(?'number'[\d]*)"
or@"(?'message'.*?) message (?'number'.*)"
-
Hi Dave, This is my requirement. I read a line from a file, which is in the following format: [Some message 123...] So I would want to create a RegEx pattern for the above format. What would be the expression for this case. I tried this but it failed while calling method RegEx.Match():
RegEx _exp = new Regex(@"^\[(?\w+)]", RegexOptions.IgnoreCase);
Sunil
sunilkpv wrote:
So I would want to create a RegEx pattern for the above format
TO DO WHAT??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak