[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

are there any string matching languages besides regex?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 56
Thread images: 4

File: bloque.png (192KB, 655x655px) Image search: [Google]
bloque.png
192KB, 655x655px
are there any string matching languages besides regex?
>>
Any language can be used to match strings.
>>
>>56723355
>are there any string matching languages besides regex?
What?
>>
>>56723398
>>56723405
I mean languages for pattern matching specifically. Regex is tailored at pattern matching and does this well but not much else; are there any others like that?
>>
>>56723437
perl
>>
>>56723355
glob?
>>
>>56723525
perl regex are still regex
>>
>>56723549
they are regex extensions, it's pretty much like C vs C++
>>
>>56723437
sed and awk
grep can be used for pattern matching, but it's not a language.
>>
lua's patterns are similar but less powerful
>>
>>56723546
yess but it's pretty limited
>>
>>56723561
all three use regex senpai
>>
https://en.wikipedia.org/wiki/Formal_language
>>
>>56723580
Well shit then. idk.
>>
>>56723565
never seen this one…looks a lot like regex with \ replaced with % which honestly isn't a bad decision
>>
So far:
* glob
* lua patterns
* Backus–Naur?
>>
>>56723561
>3 things which use regex are a replacement for regex

anon....
>>
>>56723626
wolfram patterns <http://reference.wolfram.com/language/guide/Patterns.html>
more info <http://xahlee.info/cmaci/notation/pattern_matching_vs_pattern_spec.html>
>>
>>56723437
recursive pattern matching or just simple 1:1 matching?

I do not think you can get much better than regular expressions for the finite automata-matching
>>
>>56723655
checked. all of 'em

ideal would be a backus-naur–equivalent that is as dense as regex?
>>
>>56723561

g/re/p

global / regular expression / print

Read a book you fucking idiot >>>/b/
>>
>>56723643
>>56723683
gosh, you guys
does denigrating others' knowledge make you feel more secure in your own?
>>
>>56723671
backus naur is regex though?

just several separate statements of increasing/decreasing complexity
>>
Is it retarded to use regex to parse command strings on a server ?

I have multiple clients sending bash like commands and I have a regex pattern used to match and extract parameters.

Will regex cause speed issues somehow ? The pattern is bretty solid btw and I havent been having trouble sending large commands yet.
>>
>>56723683
Hey I'm not the dumbass searching for something different just to be different when everything uses regular expressions. Get fucked.
>>
F# is great for quick and dirty recursive parsers using pattern matching and active patterns. Works every time, no matter your data format.

Perl is nice too.
>>
>>56723715
https://en.wikipedia.org/wiki/File:Chomsky-hierarchy.svg
recursively enumerable ⊃ context-sensitive ⊃ context-free ⊃ regular

regex are regular, backus-naur are context free
but I think perl regex exceed the regular class
>>
>>56723721
if you only use basic regex and no extended/perl ones you shouldn't have any problems
see <https://swtch.com/~rsc/regexp/regexp1.html>
>>
>>56723721
It's not that bad, but you should consider processing messages on client side and sending less complicated commands to server.
>>
I'm not sure what you have in mind but maybe look into Parsing Expression Grammars?

http://lambda-the-ultimate.org/node/3039
>>
>>56723768
I basically wanted a way to send any type of data through strings so I just parse straight from text , I dont know how the data could be processed any further client side considering I only send things like integers and other strings.

I really cant think of any better way to send data through server. Clients can send requests for small pieces of data or the entire set of server side variables and the server replies with the data asked. I just hate doing this through strings.
>>
>>56723838
>He sends integers as a string
>>
>>56723750
I see

If the BNF had an ordering of statements where the lower statements only referred to statements below it, not above it -- would it be implementable as a regex?
>>
>>56723898
maybe <cs.stackexchange.com> would know
>>
>>56723891
Tell me why thats retarded honeslty I cant figure out the best way to send data between server and client that isnt jamming everything in a string and extracting the parameters by parsing.

I send the entire set of variables as a string. The server only receives and sends strings so you can send them manually if you need to. I just think its retarded to send individual integers if im going to be sending the whole byte array from the string ?

At this point what the hell should I even do ? I dont want to have to play with bitshifts just to send data from client to server.
>>
>>56723976
>>56723838
consider using json?

Parsing strings with regex for arguments seems like it could be a huge disaster with injections if users type the stuff you search for as their text arguments
>>
>>56723891
for reference:

$ cat > main.c << EOF
/* error checking omitted */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
FILE *bin, *txt;
int i;

bin = fopen("binary", "wb");
txt = fopen("text", "w");

for (i = 0; i < 65535; i++) {
#define BUFSZ 12
char buf[BUFSZ];
int r = rand();

fwrite(&r, sizeof(r), 1, bin);
snprintf(buf, BUFSZ, "%d\n", r);
fwrite(buf, 1, strlen(buf), txt);
}

return 0;
}
EOF
$ cc -o main main.c
$ ./main
$ wc -c binary
262140 binary
$ wc -c text
686831 text
$ gzip text
$ wc -c text.gz
328264 text.gz

Uncompressed text vs binary ratio: 2.62
Gzipped text vs binary ratio: 1.25
this is the price of transparency
>>
>>56724114
>indentation
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
FILE *bin, *txt;
int i;

bin = fopen("binary", "wb");
txt = fopen("text", "w");

for (i = 0; i < 65535; i++) {
#define BUFSZ 12
char buf[BUFSZ];
int r = rand();

fwrite(&r, sizeof(r), 1, bin);
snprintf(buf, BUFSZ, "%d\n", r);
fwrite(buf, 1, strlen(buf), txt);
}

return 0;
}
>>
>>56724139
well looks like ideographic spaces no longer work
still never gonna use code tags
>>
>>56724139
[ code ]

[ /code ]
>>
>>56723355
Regular expressions isn't a language you fucking 12 year old.
>>
>>56724051
honestly had not considered json, but considering how I use the data I dont think code injections are a big problem.

The problem is still users sending data as another user by spoofing their name parameter.

desu am total noob at servers , this is the first server app I got working except a few basic chat clients. This shit is messing with my mind.
>>
>>56723838
you are literally describing data serializing, which can be done with xml or json with built in libraries.
>>
>>56724361
except i just send small bits of data in commands and sending a , I doubt I need this when sending commands. Perhaps for data requests json could be nice , but then again I dont need a whole framwork around the data.
>>
>>56724708
*a small bit of text using json would be retarded
>>
Writing a Parsec/Megaparsec parser is really easy
>>
Lol. Comp Sci much?
>>
>>56723355
Nice email validation Regex, OP.
>>
Yes. PEGs are vastly superior to regex.
>>
>>56723355
Regex is a concept. Any string matching probably falls under the regex umbrella
>>
File: 714px-Chomsky-hierarchy.svg.png (40KB, 714x515px) Image search: [Google]
714px-Chomsky-hierarchy.svg.png
40KB, 714x515px
>>56728887
>Any string matching

No, PEGs are context-free iirc.

Also, wouldn't all lexers fall under "string matching"?
>>
grok
>>
Not sure what Mathematica uses for its pattern recognition. It's C under the hood so probably just something standard. If you count the Wolfram language as it's own thing it's not regex though.
>>
/^((?:(?:[^?+*{}()[\]\\|]+|\\.|\[(?:\^?\\.|\^[^\\]|[^\\^])(?:[^\]\\]+|\\.)*\]|\((?:\?[:=!]|\?<[=!]|\?>)?(?1)??\)|\(\?(?:R|[+-]?\d+)\))(?:(?:[?+*]|\{\d+(?:,\d*)?\})[?+]?)?|\|)*)$/


Recursive Regex that checks for valid Regex (but not OTHER meta-regex like this one, only normal baseline complexity). Requires Perl or PCRE.
>>
Doing pattern matching in ICON is neat. Would recommend.
>>
>>56730418
>ICON

my nigga.
Thread posts: 56
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.