Fri Feb 21, 2020 5:56 pm
Login Register Lost Password? Contact Us


Finding text that does not parse PARSE

Comments and questions related to the Enterprise Control Language

Wed Dec 11, 2019 12:08 pm Change Time Zone

Hi Richard,

Cribbing from your excellent Teck Talk Episode 10 on PARSE, I've found it surprisingly easy to parse some simple text E.G.
Code: Select all
ITEM1=A,ITEM2=B,ITEM3=123456

I retrieve all the distinct matches for '<item>=<value>', so from the example above I get 3 records back, all well and good.

My problem comes in detecting invalid input, I want to report if someone has input
Code: Select all
ITEM=

with no 'value', but PARSE, as it stands, correctly does not return the invalid value but I've no indication that there was text that did not match.

Yours
Allan
Allan
 
Posts: 419
Joined: Sat Oct 01, 2011 7:26 pm

Wed Dec 11, 2019 12:18 pm Change Time Zone

Adding to this,
Preferably I would not just have an indication there was incorrect text, but the incorrect text was also returned with perhaps a BOOLEAN Bad set.
so for:
Code: Select all
ITEM1=A,Item=,ITEM2=B,ITEM3=123456,,,,,,,,

I would get back:
Code: Select all
Bad      Text Fragment
FALSE    ITEM1=A
TRUE     ITEM=
FALSE    ITEM2=B
FALSE    ITEM3=123456
TRUE     ,,,,,,,,,,

Yours
Allan
Allan
 
Posts: 419
Joined: Sat Oct 01, 2011 7:26 pm

Mon Dec 23, 2019 8:17 am Change Time Zone

Allan,

You should be able to get all the non-matches by using NOT MATCHED(pattern) as your search criteria, and returning MATCHROW() for those will allow you to see the actual non-matching records.

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1519
Joined: Wed Oct 26, 2011 7:40 pm

Fri Jan 03, 2020 12:07 pm Change Time Zone

Thanks Richard,

I'll give your suggestion a whirl.

Yours

Allan
Allan
 
Posts: 419
Joined: Sat Oct 01, 2011 7:26 pm

Fri Feb 07, 2020 4:39 pm Change Time Zone

Richard,

Finally got round to trying

PARSE(... NOT MATCHED);

Works a Treat!
All the 'Matches' return false, therefor as long as you have something in your TRANSFORM that acts on the 'else' part of the MAP or CASE (whatever), you get the bad input.

Simple

Thanks

Allan
Allan
 
Posts: 419
Joined: Sat Oct 01, 2011 7:26 pm


Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest