09-24-2014 08:19 AM
Guys,
I would like to know if there is an elegant way (maybe using regular expressions) to solve this:
incoming string looks like this:
Event Log Started: 11/10/2011 11:49:28 AM
Time, System Event
11/10/2011 11:49:29 AM, FILE SAVING ENABLED
11/10/2011 11:49:33 AM, PUMP STARTING
11/10/2011 11:49:34 AM, PUMP DISCONNECTED
11/10/2011 11:49:35 AM, PUMP STOPPED
11/10/2011 11:49:36 AM, PUMP STARTING
11/10/2011 11:49:42 AM, PUMP RUNNING
11/10/2011 11:49:43 AM, STARTING CURRENT: 2.10 (A)
I want to be able to detects incoming strings that have this sequence:
PUMP STARTING
PUMP DISCONNECTED
PUMP STOPPED
PUMP STARTING
PUMP RUNNING
my first approach was to search for one at the time and then check indexes (but that looks to me to be messy)
any help will be appreciated.
regards,
Solved! Go to Solution.
09-24-2014 08:36 AM
@El_Tipo wrote:
Guys,
I would like to know if there is an elegant way (maybe using regular expressions) to solve this:
incoming string looks like this:
Event Log Started: 11/10/2011 11:49:28 AM
Time, System Event
11/10/2011 11:49:29 AM, FILE SAVING ENABLED
11/10/2011 11:49:33 AM, PUMP STARTING
11/10/2011 11:49:34 AM, PUMP DISCONNECTED
11/10/2011 11:49:35 AM, PUMP STOPPED
11/10/2011 11:49:36 AM, PUMP STARTING
11/10/2011 11:49:42 AM, PUMP RUNNING
11/10/2011 11:49:43 AM, STARTING CURRENT: 2.10 (A)
I want to be able to detects incoming strings that have this sequence:
PUMP STARTING
PUMP DISCONNECTED
PUMP STOPPED
PUMP STARTING
PUMP RUNNING
my first approach was to search for one at the time and then check indexes (but that looks to me to be messy)
any help will be appreciated.
regards,
The most elegant way to do something is the way you've figured out for yourself. 😉
Go ahead and try. We promise not to laugh too hard. (Aww, j/k - I hate RegEx, so my code would probably look worse than whatever you can show us.) 😉
09-24-2014 08:36 AM
Hi Tipo,
- read in your file as text string.
- use SpreadsheetStringToArray with comma as delimiter and format "%s"
- index the 2nd column and search for strings starting with "PUMP"…
In case you receive strings as single lines you only need to look for "PUMP"…
09-24-2014 08:41 AM
Billko,
Before you were a Low-level minion I was around LV for some time.
If you are not going to add to the question anything with substance please dont waste the energy.
I posted the question to see if someone with more experience than me doing regex could figure out my problem quickly.
I have never intended on the various question i have posted to get easy answers without try if first.
09-24-2014 08:48 AM
I used a loop to generate the larger regular expression needed to find your terms:
A more general regexp might be sufficient.
09-24-2014 08:50 AM
jcrmody,
right what I was lookig for thanks a bunch for your help.
regards,
09-24-2014 08:50 AM
This is what I'd do...
09-24-2014 08:59 AM
Oops! I didn't notice you needed the exact sequense. Misread. I found myself looking at Jim's code thinking "that is way too complex".
My solution would still work with some adjusting, but his is better.
09-24-2014 08:59 AM
the input string can have any flavor example:
Event Log Started: 11/11/2011 1:44:19 PM
Time, System Event
11/11/2011 1:44:19 PM, FILE SAVING ENABLED
11/11/2011 1:44:24 PM, PUMP STARTING
11/11/2011 1:44:30 PM, PUMP RUNNING
11/11/2011 1:44:31 PM, STARTING CURRENT: 1.90 (A)
11/11/2011 2:39:10 PM, PUMP DISCONNECTED
11/11/2011 2:39:11 PM, PUMP STOPPED
11/11/2011 2:39:21 PM, PUMP STARTING
11/11/2011 2:39:26 PM, PUMP RUNNING
11/11/2011 2:39:27 PM, STARTING CURRENT: 2.00 (A)
the string should be desregard because does not contain the exact sequence.
09-24-2014 09:39 AM - edited 09-24-2014 09:41 AM
@El_Tipo wrote:
Billko,
Before you were a Low-level minion I was around LV for some time.
If you are not going to add to the question anything with substance please dont waste the energy.
I posted the question to see if someone with more experience than me doing regex could figure out my problem quickly.
I have never intended on the various question i have posted to get easy answers without try if first.
I know you were around for a long time. I apologize if you didn't pick up on my humor. Part of the humor was BECAUSE I knew you were experienced. I was also laughing at myself because I know my attempts probably would look worse than ANYthing you could show us.
And I was actually contributing to the topic by trying to encourage you to post something first so we can all get a look at it and help you out.