regular expression trouble
Posted: Fri Mar 25, 2011 12:36 pm
Hi. The forum that I normally take this tedious stuff to has changed something and now I can't login, so I hope you'll forgive this.
Basically, it's all about regular expressions, though in C#, which hopefully won't make a difference.
I'm trying to match an entire line, which may be structured in a very specific, though somewhat complicate way.
To illustrate my issue I'll simply give two examples:
NB, these lines are cut of at the end so ']' does not mark the end of the string.
The first part is easy enough, though it may be done in a better way:
Here it shows clearly that I've never worked much with regular expressions before, but I'm learning fast.
Now the next part is more tricky. Initially I thought that
would do the trick, but after testing it is clear that something is very wrong. Then I considered \b, but that obviously didn't work and so on and so forth. I've spend the better part of the day figuring out how to do this, but with no luck. Any tutorial or guide I've found have left out the stuff I need to know, or else I'm just... Well, not as clever as I thought I was.
This is the only trouble I've got by the way.
Hope you'll help me. Kind of in a hurry.
Best regards.
Basically, it's all about regular expressions, though in C#, which hopefully won't make a difference.
I'm trying to match an entire line, which may be structured in a very specific, though somewhat complicate way.
To illustrate my issue I'll simply give two examples:
Code: Select all
2011-03-22 20:28:43 [Team]
2011-03-22 20:28:43 [Local]
The first part is easy enough, though it may be done in a better way:
Code: Select all
^\d\d\d\d\-\d\d\-\d\d \d\d:\d\d:\d\d
Now the next part is more tricky. Initially I thought that
Code: Select all
\[[/Team//Local/]\]
This is the only trouble I've got by the way.
Hope you'll help me. Kind of in a hurry.
Best regards.