The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Regex Programming
|
Request Parsing Help
Discuss Request Parsing Help in the Regex Programming forum on Dev Shed. Request Parsing Help Regular expressions forum covering PCRE and POSIX techniques, practices, and standards. Regular expressions help shorten coding time by providing the ability to compact many lines of code into one string.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 9th, 2012, 06:57 PM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 3
Time spent in forums: 52 m 30 sec
Reputation Power: 0
|
|
|
Request Parsing Help
Hi,
This is what I would like to parse
Code:
Slot Description State Command Status
============================================================================
C00 XLR Control Module(M) diag on-line
O00 Optical Tributary Module diag on-line
O01 Optical Tributary Module diag on-line
O02 Optical Tributary Module diag on-line
O03 Optical Tributary Module diag on-line
O04 Optical Tributary Module diag on-line
O05 - slot empty
O06 - slot empty
O07 - slot empty
O08 - slot empty
O09 - slot empty
X00 Optical Switching Module diag on-line
X01 Optical Switching Module diag on-line
X02 Optical Switching Module diag on-line
X03 Optical Switching Module diag on-line
X04 Optical Switching Module diag on-line
X05 Optical Switching Module diag on-line
X06 Optical Switching Module diag on-line
X07 Optical Switching Module diag on-line
X08 Optical Switching Module diag on-line
X09 - slot empty
C01 XLR Control Module(S) diag on-line
T00 Timing Sync Module diag on-line
T01 Timing Sync Module diag on-line
Here is what I think ought to work (but does not)
Code:
(?<Name>[COXT]\d\d)\s+([\(\)\w]*\s)*-?\s{3,}(?<value>[\w\s-]*)
This partial expression works
Code:
(?<Name>[COXT]\d\d)\s+([\(\)\w]*\s)*-?\s{3,}
Even this works
Code:
(?<Name>[COXT]\d\d)\s+([\(\)\w]*\s)*-?\s{3,}(?<value>[\w-]*)
Your help will be appreciated.
(Note: there may be other "States".)
ThatSamIam
|

June 12th, 2012, 07:47 PM
|
 |
Contributing User
|
|
Join Date: Apr 2012
Location: spaceBAR Central
|
|
|
Ok, I see your input but what do you want your output to look like?
|

June 12th, 2012, 09:06 PM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 3
Time spent in forums: 52 m 30 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by spacebar208 Ok, I see your input but what do you want your output to look like? |
Spacebar208,
Thanks for looking at this. At ~650 views and no responses, I was getting worried.
I would like:
Name, Value
(C00, diag on-line)
(O00, diag on-line)
(O01, diag on-line)
(O02, diag on-line)
(O03, diag on-line)
(O04, diag on-line)
(O05, slot empty)
(O06, slot empty)
(O07, slot empty)
(O08, slot empty)
(O09, slot empty)
(X00, diag on-line)
(X01, diag on-line)
(X02, diag on-line)
(X03, diag on-line)
(X04, diag on-line)
(X05, diag on-line)
(X06, diag on-line)
(X07, diag on-line)
(X08, diag on-line)
(X09, slot empty)
(C01, diag on-line)
(T00, diag on-line)
(T01, diag on-line)
Thanks again,
ThatSamIam
|

June 14th, 2012, 01:19 PM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 3
Time spent in forums: 52 m 30 sec
Reputation Power: 0
|
|
Ok, I figured it out:
PHP Code:
(?<Name>[COXT]\d\d)\s+([\(\)\w]*\s)*-?\s{5,}(?<Value>(\w+[\s-]{0,1})*$)
Thanks to those who gave it a shot.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|