|
Happy day ! I could resolve a part of my regex task in Expresso.
For the record and other users: Obviously ".*" for "any character / any number of repetitions" is not good enough to capture a CRLF! Trying to capture it with \r wasn't the right thing either, it took "\r\n" to match the group together with the first line! Here's the current status of the regex:
\[(?<Grp>.*)\]\r\n(?<Keyword>\w+)\s*=\s*(?<Value>.*)\r
The ultimate question would now be:
Of course the first key-value-pair after the group header isn't enough.
How can I include its repetitions into my match now?
@ Luc: Thanks for the hint. I guess it was more a matter with my own attention monster that I had here...
@ Admin: Pls excuse me double-posting with the VB forum. This new forum obviously isn't too known yet, so that I had more forwarding answers there before being told to shift my post here...
|
|
|
|
|
Michael,
I'm not really a regex expert, but I would tackle your problem with two regex and two foreach; the first regex would locate groups, the second would parse the key=value pairs within a group. I've never seen this done with a single regex.
BTW: I don't like your \r\n stuff at all. One normally uses the symbols for start-of-line (^) and end-of-lin ($)e, avoiding problems with matching things on the first line and last line (your input may or may not end on \r or \r\n).
FYI: I have some similar regex stuff in my article CP Vanity[^] which scrapes some of the CodeProject web pages. Similiar meaning two regexes, two foreach loops.
|
|
|
|
|
Don't you need to double (escape) the backslashes? This is part of why I wrote my RegexTester[^].
|
|
|
|
|
the OP started with a "Dim", in VB there is no escape mechanism AFAIK.
|
|
|
|
|
I need sleep. This working for eight hours a day sucks, why do people do it?
|
|
|
|
|
|
Making tools to help with regular expressions must be fun, because I made one too. Looks kinda like yours.
|
|
|
|
|
As hot as hell.
Those are pretty regular, aren't they?
L u n a t i c F r i n g e
|
|
|
|
|
|
"Hmmmm... it's never done that before."
L u n a t i c F r i n g e
|
|
|
|
|
You two are in your own little Universe, aren't you?
Mind if I join you?
Will Rogers never met me.
|
|
|
|
|
so you decide to butt in?
there actually are a few more expressive regulars, you know.
|
|
|
|
|
Luc Pattyn wrote: expressive regulars
Nice...
Will Rogers never met me.
|
|
|
|
|
yet another new forum. is there a clearance sale going on?
|
|
|
|
|
There must be -- I asked and I received. Now we have to promote it.
|
|
|
|
|
you asked for it. Now what is your question?
|
|
|
|
|
If tin whistles are made of tin, what do they make foghorns out of?
|
|
|
|
|
you have been waiting several years for a regex forum, and when you finally get it, you post a question that does not even belong here?
|
|
|
|
|
I generally don't have such questions, but I like answering responding to them.
|
|
|
|
|
PIEBALDconsult wrote: tin whistles are made of tin
I can another pattern here.
|
|
|
|