Why the fuck does regex exist?

Why the fuck does regex exist?

Attached: regex.jpg (489x291, 15K)

Other urls found in this thread:

regexr.com
robelle.com/smugbook/regexpr.html#expression
twitter.com/SFWRedditImages

to make string manipulation easier

I'm seeing a lot of regex hate on Jow Forums these days. It seems the IQ of this board has dropped yet again.

It's a domain specific language that lets you describe complex text patterns for the purposes of pattern matching, text filtering, input validation, or conditional search and replace.

Because its useful as fuck. Sorry youre too low IQ to appreciate it

Because some dumbass made it and thought it was cool. Little did they know the thing would be extended into the modern engines of JavaScript regexp, perl regexp, c# regexp and all the other fucked up dumb shit people make using regexps instead of parser generators, combinators other things.

I'm not a programmber but sometimes need to use regex. I'll never get my head around it, its too weird to me.

I'm better at pattern matching than programming and regex is just too alien for me to grasp
my IQ is measured to be around 117...I'm 1200 rated in chess...definitely a brainlet by some of the regulars of Jow Forums but hey I try

I didn't know somebody with 117 IQ could be such a fucking idiot.

It's perfect for HTML parsing

i thought so too until i memorized most of the important things. i spent 2017 and 2018 learning regex for Jow Forums filtering - looking at a cheat sheet on average once a week - and it eventually became second nature

Then it's not related to IQ because I'm a 3rd worlder with 93 IQ and learnining regex took me just an hour when I was 15

>he thinks he’s learned regex
Regular expressions take you a lifetime to master.

>i can't be bothered to read the documentation

Elaborate

Go back to r*ddit, Christopher.

Regex is nice for general purpose string matching and find/replace.

Suppose you have dynamically inspected the name of a class method and you want to determine if it ends in "_test". Some people might say just doing it by hand with custom code is sufficiently easy. But when your codebase is 50k LOC and you have a constant stream of new contributors, you really want to do everthing you can to keep your code simple and easy to understand for people unfamiliar with the codebase.

Regexes are an example of using a more powerful tool than you really need because the tool is standard, simple and optimized.

At my work the job of updating and maintaining all the regex's searching terabytes of content daily is given to the dumbest cunts we have.
By the end of the first day they are competent. By the end of the week they are perfectly capable of writing huge monstrosities that just werk and most devs on earth couldn't parse.
It's a great tool and isn't any harder to pick up than a programming language.
Just use a regex calculator like normal people and get on with your life if it's a one off thing every now and then.

Because it's really powerful for string matching? I can't imagine a world without it. Any implementation to progromatically search a document for a pattern would end up being similar to regex in some way.

it's fast, it's able to do a bunch, and there's fairly solid theory behind it
kinda wish it wasn't such a write-only mess, reading a regex to figure out what it does just blows fucking ass

Regular expressions are weird because they are a construct of formal language theory (regular languages).

The fact that they can be used for search patterns is just a happy accident.

exactly
while it makes sense that it's a fire and forget type of syntax, it's just plain ugly
I don't do a lot of datamining but I'm probably going to start doing that as I develop conspiracy theories...maybe it's just that I haven't set up a proper environment to see their usage or I haven't got a proper learning resource.
which board is that again?

A good use is parsing HTML.

Attached: kurisu2.jpg (937x960, 183K)

ask not why something exists, ask why something does not

>it’s impossible to have a pattern matching system that doesn’t take a whole year to learn, goy. Just use regexp and don’t complain.

Every programmer who uses regex should ideally have detailed knowledge of how they work under the hood. It's prossible to write regexs that when matched against certain strings can lock up your service. One should know to avoid that.

so I can whip out a function to tokenize an expression in a few seconds

Because it is simple way to parse some text and it works.
I use it for search and substitution in Vim, for grepping the output of shell utilities and for autohide filters on Jow Forums.
Better question, op: what do you suggest instead? Some object-oriented stuff?
"\(.*\)"
Easy.

This is not possible with proper regular expressions, due to the pumping lemma for regular languages. Some regular expression packages included with languages provide extensions that make this possible.

Topkek, underrated

so some morons can feel patrician
i know how to write programs in brainfuck but that doesn't change the fact that it's stupidly hard for humans to read

it only took me a year to learn because i didn't have to use it that frequently.
that would also match "(lorem ipsum))", a string with unbalanced parenthesis. regular expressions can't handle stuff like that well, you need another pattern-matching language like rosie

spbp

>he does it wrong
>Easy.
even regexlets don't get regex

Attached: 1466187730152.png (655x653, 297K)

So you can write a 1-paragraph abomination doing some critical function that nobody will ever be able to parse and will guarantee you job security. Bonus points if that critical function has nothing to do with pattern matching.

But can you write them in APL?

.*

>117
That is, eh... kinda low don't you think? Remember you have to compete with children, elders and autists, too. Not to mention those farmers, blue-collars, sportsmen... aren't that famous for their IQ score.

Btw, regex is better to grasp if you try to write a text parser before, which every cs students had been doing.

> captured group, exclude, lookahead, lookbehind, greedy vs non-greedy, extensions, charset, unicode...

I don't think you can learn regex in a few hour.

All of this is super simple stuff.

dude my sister knows regular expressions because they are useful. fuck off

i want to fuck your sister

It's convenient.

i'm curious: does your sister has a dick?

Character classes:
., [], [^] and shorthands
Quantifiers:
*,?,+, {,} and the lazy modifier - apply to character classes
() makes a group you can use the same way as a character class. Also you can get whatever a group matched by number(corresponds to the number of the opening parenthesis) or by name.
Shit that modifies the behavior of a group:
Named group
Negative/positive lookahead/lookbehind
if/else
balancing group
Regex options.
Literally what else is there to learn. It's not even a brainlet filter, it's a total troglodyte filter.

Oh and also ^ as the beginning of a string and $ as the end. | is logical or for groups.

regexr.com
15 minutes tops

>In before StackOverflow

everything should be point and click, or better yet swipe and pinch

>Why the fuck does regex exist?
it makes a monkey out of people who dont know, don't it though?

\A and \z for multi line string

unicode character sets, like \p{Han} or \p{Katakana}

and difference between regex engines (e.g PCRE vs Oniguruma) and fighting the system when your favorite language of choice don't have that regex feature (like lookbehind)

>Why the fuck does regex exist?
It doesnt. It only exists if you know about it
there is no actual existence for regex to have.
If you dont know about it then there are no examples you can point at and say, that's regex.
It only exists in the same way that a personal memory exists

Non-capturing groups come to mind, but otherwise yeah

i already did you''re too late

>writing huge monstrosities that just werk and most devs on earth couldn't parse
That's my only complaint about regex. I write shit and that I can't read a week later.

It's simple enough that someone with no understanding of programming languages can at least make use of a webparser. Just yesterday I had to change weather apis, and it was fairly painless even though the apis had completely different layouts.

Attached: img000010.png (907x1300, 634K)

My IQ is 64 and I don't find regex confusing. I'm autistic btw

RegEx is a regular language. It's simple, and it also has limitations since it can't handle Context-Free Grammars.

If you're having issues using it maybe you need to read up on regular languages. They're dead simple.

^$

Who else wrote a regex engine in c for fun?
Bonus points for fully unit tested.
Come on geee...

Because it makes filtering posts on Jow Forums easier
btw if you haven't already, add
"/>>\d*\n>>\d*\n>>\d*\n>>\d*\n>>\d*\n>>\d*\n>>\d*\n>>\d/i;"
to your 4chanX filter to hide posts that reply to more than 7 people in a row

Irrefutable evidence that IQ is a shit indicator of intelligence

to grep gooder
robelle.com/smugbook/regexpr.html#expression