Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #351098
| From | owl <owl@rooftop.invalid> |
|---|---|
| Newsgroups | comp.os.linux.advocacy |
| Subject | Re: A maybe interesting code challenge |
| Date | 2016-04-21 01:54 +0000 |
| Organization | O.W.L. |
| Message-ID | <thjgu0a.af@rooftop.invalid> (permalink) |
| References | <nf87hq$ndh$1@dont-email.me> <53055ce2-1df3-4a84-b83f-e6483f0a30f9@googlegroups.com> <nf88nm$rrv$1@dont-email.me> |
DFS <nospam@dfs.com> wrote:
> On 4/20/2016 11:45 AM, Steve Carroll wrote:
>> On Wednesday, April 20, 2016 at 9:37:44 AM UTC-6, DFS wrote:
>>> Parse a search string composed of 1, 2 or 3 parts, separated by a
>>> semicolon, into 2, 4 or 6 variables (field1, value1, etc)
>>>
>>> Search string: use 1 part : state=GA use 2 parts: state=GA ; name =
>>> Burger King use 3 parts: state=GA ; name = Burger King ; zip like
>>> 303*
>>
>> I can see for the state and zip but, in any given, random string, how
>> would you be able to exactly determine what the name is? Is this
>> related to your previous stuff where the name consists of everything
>> minus the other bits of data (then it makes sense)?
>
>
> wildcards. The search routine is almost infinitely variable.
>
> city = Atlanta
> state=TN ; name like Burger* ; street like Main*
> state=GA ; name like *pizza ; zip = 30017
>
> all are valid inputs
>
> This parser is part of a real VBScript program I'm writing to replace
> Fabian Russell at his Windows job.
>
>
>
>>> If someone posts a 2-line perl solution, I'm hurling.
>>
>> Hehe ;)
>
>
> It makes sense for perl to be shorter, but to be 1/3 the lines and run
> in (maybe) 1/10th the time is kind of embarrassing for VB. I say maybe
> because I haven't run Sandman's script on my own Linux system yet.
>
>
This one's fairly slow: times between 0.07 sec and 0.09 sec
just for these few lines.
anon@lowtide:~/code/dfs/nah$ cat input
state=GA
state=GA ; name = Burger King
state=GA ; name = Burger King ; zip like 303*
city = Atlanta
state=TN ; name like Burger* ; street like Main*
state=GA ; name like *pizza ; zip = 30017
anon@lowtide:~/code/dfs/nah$
anon@lowtide:~/code/dfs/nah$ ./vars input
var field1 = 'state'
var value1 = 'GA'
var field2 =
var value2 =
var field3 =
var value3 =
-----
var field1 = 'state'
var value1 = 'GA'
var field2 = 'name'
var value2 = 'BurgerKing'
var field3 =
var value3 =
-----
var field1 = 'state'
var value1 = 'GA'
var field2 = 'name'
var value2 = 'BurgerKing'
var field3 = 'zip'
var value3 = '303*'
-----
var field1 = 'city'
var value1 = 'Atlanta'
var field2 =
var value2 =
var field3 =
var value3 =
-----
var field1 = 'state'
var value1 = 'TN'
var field2 = 'name'
var value2 = 'Burger*'
var field3 = 'street'
var value3 = 'Main*'
-----
var field1 = 'state'
var value1 = 'GA'
var field2 = 'name'
var value2 = '*pizza'
var field3 = 'zip'
var value3 = '30017'
-----
anon@lowtide:~/code/dfs/nah$
anon@lowtide:~/code/dfs/nah$ cat vars
#!/bin/bash
echo "var field1 = " > labels
echo "var value1 = " >> labels
echo "var field2 = " >> labels
echo "var value2 = " >> labels
echo "var field3 = " >> labels
echo "var value3 = " >> labels
sed -e 's/$/;/g' ${1} | csplit -s -z - /\;/ {*}
sed -i 's/;/\n/g' xx*
sed -i 's/like/=/g' xx*
sed -i 's/ //g' xx*
sed -i 's/=/\n/g' xx*
sed -i 's/\(.*=\)\(.*\)/\2/g' xx*
sed -i '/^$/d' xx*
sed -i '/^\s$/d' xx*
sed -i "s/^/\\'/g" xx*
sed -i "s/$/\\'/g" xx*
for i in xx*;do paste labels ${i}>labels${i};echo "-----">>labels${i};done
cat labelsxx* | sed -e 's/\t//g'
rm xx*
rm labels*
anon@lowtide:~/code/dfs/nah$
Back to comp.os.linux.advocacy | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-20 11:37 -0400
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-20 08:45 -0700
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-20 11:57 -0400
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-20 09:02 -0700
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-21 01:54 +0000
Re: A maybe interesting code challenge Steve Carroll <fretwizzen@gmail.com> - 2016-04-20 18:57 -0700
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-21 02:45 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-20 23:01 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-21 03:56 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-21 11:06 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-21 16:13 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-21 17:27 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 19:07 +0000
Re: A maybe interesting code challenge Steve Carroll <fretwizzen@gmail.com> - 2016-04-20 19:01 -0700
Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 09:37 +0000
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-22 08:33 -0400
Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 22:03 +0000
Re: A maybe interesting code challenge Richard King <kingsley651@webby.org> - 2016-04-22 18:22 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 19:48 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-22 17:24 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 22:18 +0000
Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 22:26 +0000
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 22:43 +0000
Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 22:50 +0000
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 22:57 +0000
Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-23 13:07 +0000
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-23 09:58 -0400
Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 21:48 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-22 17:00 -0400
Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 21:56 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-22 19:39 -0400
Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-23 15:25 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 13:14 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-23 18:37 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 16:50 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-23 21:15 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 18:36 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-23 23:24 +0000
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-22 08:21 -0400
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-22 10:04 -0400
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-23 00:09 -0400
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 00:18 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-23 05:59 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 12:46 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-26 19:04 +0000
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-26 20:40 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 17:48 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-26 22:14 +0000
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-23 23:15 -0400
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 23:30 -0400
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-24 08:52 -0400
Re: A maybe interesting code challenge Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-24 10:06 -0400
Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-24 15:59 +0000
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-24 15:45 -0400
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-25 10:19 -0400
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-25 20:26 -0400
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-25 23:24 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-26 05:03 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 11:40 -0400
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-25 15:14 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-25 12:05 -0400
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-25 18:06 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 12:41 -0400
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-26 18:03 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 17:39 -0400
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 05:50 +0000
Re: A maybe interesting code challenge chrisv <chrisv@nospam.invalid> - 2016-04-27 06:43 -0500
Re: A maybe interesting code challenge William Poaster <wp@dev.null> - 2016-04-27 13:11 +0100
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 13:32 +0000
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 07:32 -0700
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 15:02 +0000
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 08:17 -0700
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 16:21 +0000
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 09:42 -0700
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 21:39 +0000
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-27 23:25 +0000
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 05:34 +0000
Re: A maybe interesting code challenge vallor <vallor@cultnix.org> - 2016-04-28 05:37 +0000
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 05:42 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 11:45 -0400
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 16:23 +0000
Re: A maybe interesting code challenge Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-04-27 18:40 +0200
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 09:58 -0700
Re: A maybe interesting code challenge Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-04-27 20:57 +0200
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 12:06 -0700
Re: A maybe interesting code challenge Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-04-27 22:44 +0200
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 13:38 -0400
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 11:07 -0700
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 15:51 -0400
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 13:30 -0700
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-27 21:38 -0400
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-28 11:33 -0400
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-28 09:14 -0700
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-28 14:17 -0400
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 18:49 +0000
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 08:42 -0700
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-29 13:42 -0400
Re: A maybe interesting code challenge Snit <usenet@gallopinginsanity.com> - 2016-04-29 10:54 -0700
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 11:20 -0700
Re: Snit digest 214 / 2016-04-29 Melzzzzz <mel@zzzzz.com> - 2016-04-30 00:31 +0200
Re: Snit digest 214 / 2016-04-29 DFS <nospam@dfs.com> - 2016-04-29 19:00 -0400
Re: Snit digest 214 / 2016-04-29 DFS <nospam@dfs.com> - 2016-04-30 10:36 -0400
Re: Snit digest 214 / 2016-04-29 chrisv <chrisv@nospam.invalid> - 2016-05-02 07:54 -0500
Re: Snit digest 214 / 2016-04-29 Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-05-02 15:55 +0200
Re: Snit digest 214 / 2016-04-29 Snit <usenet@gallopinginsanity.com> - 2016-05-02 07:23 -0700
Snit digest 215 / 2016-05-02 Sandman <mr@sandman.net> - 2016-05-02 14:39 +0000
Re: Snit digest 215 / 2016-05-02 Snit <usenet@gallopinginsanity.com> - 2016-05-02 07:54 -0700
Re: Snit digest 214 / 2016-04-29 Sandman <mr@sandman.net> - 2016-05-02 14:36 +0000
Re: Snit digest 214 / 2016-04-29 Snit <usenet@gallopinginsanity.com> - 2016-05-02 07:53 -0700
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 11:11 -0700
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 14:44 -0700
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-29 17:53 -0400
Re: A maybe interesting code challenge Melzzzzz <mel@zzzzz.com> - 2016-04-29 23:56 +0200
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-29 18:09 -0400
Re: A maybe interesting code challenge Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-29 19:09 -0400
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-30 07:31 -0700
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-05-01 08:21 +0000
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-05-01 08:47 -0700
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-05-02 14:54 -0400
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-05-02 21:54 -0400
Re: A maybe interesting code challenge GreyCloud <mist@cumulus.com> - 2016-04-28 15:39 -0600
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 08:48 -0700
Re: A maybe interesting code challenge GreyCloud <mist@cumulus.com> - 2016-04-29 16:57 -0600
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-27 21:33 -0400
Re: A maybe interesting code challenge Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-28 05:45 -0400
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 21:32 +0000
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-27 21:48 -0400
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 22:57 -0400
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 05:44 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-29 16:32 -0400
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 23:05 -0400
Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-28 03:20 +0000
Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-28 09:52 -0400
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-29 02:46 -0400
Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 08:33 -0700
Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-30 09:31 -0400
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 05:42 +0000
Re: A maybe interesting code challenge vallor <vallor@cultnix.org> - 2016-04-28 06:17 +0000
Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 06:56 +0000
Re: A maybe interesting code challenge Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-28 05:46 -0400
csiph-web