I have written this very straight forward regex code
using System;
using System.Text.RegularExpressions;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string lines = "2019-05-07 11:50:28, INFO Ayush Singhania, Level 1, EID: 1001, UID: ayush.power, Message: Create a Job";
Regex pattern = new Regex(@"(?.*?\s)(?
The Output for the following is:
2019-05-07
11:50:28
Ayush Singhania
Level 1
1001
ayush.power
........... (The Last Line is Blank)
Everything is working fine excel for the last group - "Message"
It does not print anything. Can anyone suggest why is it so?
Also i think my regex pattern is correct. Check it here https://regex101.com/r/ysawNT/1
Answer
Apart from using the wrong message Groups["Message"]
which should be MSG
, the last part is empty because the last part has no boundary set and the non greedy .*?
is also satisfied to match nothing.
What you could do is match the rest of the string using (?
No comments:
Post a Comment