RegEx

leobm, German
@leobm@norden.social avatar

The ?x modifier/flag is nice, never used it before.
Makes it possible to include commentary inside complicated patterns.

original source: https://polar.sh/eval/posts/named-capturing-groups-in-clojure

chrastecky,
@chrastecky@phpc.social avatar

Lo and behold, fellow mortals of the programmer variety! I find myself embarking upon a most arduous quest.

One that shall test the mettle of my coding prowess... Yes, thee heard right.

I dare to dance with the elusive and powerful entity known as... the #regex #email #validation!

heiglandreas,
@heiglandreas@phpc.social avatar

@chrastecky All right! 3 step email verification:

  1. No '@', no email address
  2. No MX entry in DNS for the part *after" the '@', no email address
  3. No response to a link in an email to the email address, No email address.

Everything else might look like an email address, but it isn't.... 🤷

heiglandreas,
@heiglandreas@phpc.social avatar

@chrastecky And while

ändi@stella.maris.solutions

looks like a valid email-address (if it doesn't, check your algo) ir is about as valid as "hello world" as an email address.

But that might just be different expectations of what a valid email address is. 🤷

When your customer is happy with above string being considered a "valid email address", then everything is fine...

lizardbill,
@lizardbill@hachyderm.io avatar

You can't parse [X]HTML with regex. #regex #html https://stackoverflow.com/a/1732454/1288

SirTapTap,
@SirTapTap@mastodon.social avatar
villetakanen,
@villetakanen@mementomori.social avatar
NireBryce,
@NireBryce@hachyderm.io avatar

does there yet exist any application that can take a multi-selection and spit out a #regex that will match that in any file going forward?

necrosis, German
@necrosis@chaos.social avatar

Liebe Informatik Lehrkräfte, bitte bringt euren Schülerinnen und Schülern bei.

Es hilft im Job ungemein. 😅
Ich wünschte ich hätte das schon in der Schule gelernt. 🥹

Linkshaender,
@Linkshaender@bildung.social avatar

@hobbypaedagoge ich grätsche mal rein 😉
Suchen (und Ersetzen) von Text
Parsen von Logfiles
Validieren von Daten/Eingaben (nein, keine Mailadressen!)
Daten bereinigen
Extrahieren von Infos aus Textdateien

Anwendungstipp: awk lernen.

Informatik-Unterricht: Automatentheorie, formale Sprachen, Parsing

Regex sind ein scharfes Schwert, wie dieses sollte der Umgang geübt werden (s XKCD-Cartoon)
@necrosis

mina,
@mina@berlin.social avatar

@Linkshaender

See me whilst presenting common command line tools to Windows users:

@hobbypaedagoge @necrosis

alter_unicorn,
@alter_unicorn@masto.bike avatar
alter_unicorn, (edited )
@alter_unicorn@masto.bike avatar

Did you?

VoronoV,
@VoronoV@boitam.eu avatar

@alter_unicorn Je ne sais pas de quoi il s'agit ni ce que ça veut dire mais j'ai répondu OUI pour participer 😂

stux,
@stux@mstdn.social avatar

How to #REGEX

Powerfromspace1,
@Powerfromspace1@mstdn.social avatar

@stux accurate 😉

Wen,
@Wen@mastodon.scot avatar

@stux @nrmacdonald I find it helps with my more interesting emacs commands.

rdela,
@rdela@mastodon.social avatar

Chat log from this morning’s with @zachleat + @mikeneu from @cloudcannon, in which I clumsily praise @paulcuth, @robb, and @bobmonsour among others!
https://gist.github.com/rdela/e8facf1a8a31ea5223c42075cbaa9bb2

Follow on Twitch
https://www.twitch.tv/cloudcannoncms

Subscribe on YouTube
https://www.youtube.com/@cloudcannon

Today's ep. https://youtu.be/Pt5CWtEPmBM

Bonus I use to clean up the copy pasted Discord chat…

(?# Space out copy-pasted discord chat)  
(?# find )  
^(.+)\n:\s?  
(?# replace )  
\n$1:\n  
rdela,
@rdela@mastodon.social avatar
rdela,
@rdela@mastodon.social avatar
maxleibman,
@maxleibman@mastodon.social avatar

I’ve got an email-parsing project that will require some serious regular expressions.

It’s been a long while since I’ve written any regex. Can anybody recommend any good resources for putting off or avoiding doing it?

kyleejohnson,
@kyleejohnson@jawns.club avatar

@maxleibman @aronow this won’t help you procrastinate, but https://regexr.com is one of my favorite tools once I’m close to the expression I want. It lets you test expressions on text you put in, so you can tweak your expression and see the result changes instantly.

benzucker, German
@benzucker@maly.io avatar

Any wizards here?
Is there a way to match multiple linebreaks regardless of the content but only if the number of linebreaks exceeds a value like 5?

benzucker,
@benzucker@maly.io avatar

@barubary
Well there is most likely something nicer than this: \n.+\n.+\n.+\n

barubary,

@benzucker n(.*n){3}

mgorny, Polish
@mgorny@pol.social avatar

Paczka Pythona (nie mylić z wbudowanym modułem re) zbudowana jest w oparciu o szczegóły implementacji CPythona i nie obsługuje poprawnie (i autor zapowiada, że może w końcu zablokować kompilację na PyPy). Jednakże wygląda na to, że wymagająca jej paczka działa bez problemów ze zwyczajnym re.

Dzisiaj przechodzi z łatania w sposób niedoskonały paczki regex, i ignorowania szczególnych przypadków, w których nie zadziała, na rzecz łatania re-assert. Chciałbym wysłać tę trywialną łatkę autorowi, ale — jak już wcześniej narzekałem — dostałem niegdyś bana, autor nie potrafi powiedzieć dlaczego, ale nie przeszkadza mu to uważać bana za sprawiedliwego. Może po prostu proaktywnie banuje devów dystrybucji Linuksa.

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8413cf2c2955533fdf212fea3970c99cf193d4a1
https://github.com/mrabarnett/mrab-regex/issues/521
https://github.com/mrabarnett/mrab-regex/issues/404

snacktraces,
@snacktraces@hachyderm.io avatar

Need a regex for a MAC address?

On a project a while back I needed one and created it. Thought I would share here with everyone.

https://snacktraces.com/blog/regex-for-mac-address.html

barubary,

@snacktraces does c+++ not support [[:xdigit:]]?

jpaskaruk,
@jpaskaruk@growers.social avatar

What else is as incredibly impressive, and at the same time as horrifically ugly, as #RegularExpressions?

By the way, if you need to detect #chords in a text chord chart, here is the #regex you need:

"A-G?(maj|min|m|M|+|-|dim|aug)?[0-9|11|13](sus)?[0-9|11|13](add)?[0-9|11|13]*(/A-G?)?"

edit: any #Musicians out there, can you think of any edge-case chords I should test/adjust to catch? This will be part of a Free chord chart organizer, hit me with your worst.

#Programming

jpaskaruk,
@jpaskaruk@growers.social avatar

@barubary

I reached that with some modifications to something I found somewhere, and the impression I've got is that you can use | as a logical OR within a set like that.

I could be wrong there, I'll check up on that. But in the meantime, a real musical chord that fails to properly match against the regex will be more useful to me.

For the moment I'm considering it a solved problem, cause now I need to put on my javascript wetsuit and implement this into a web ui...

https://github.com/dnotes/markdown-it-chords

barubary,

@jpaskaruk | only means OR outside of a set like that. Within a [ ] set, every character is already OR'd (e.g. [abc] matches a or b or c, and [a|b] matches a or | or b).

youronlyone,
@youronlyone@c.im avatar

To my fellow #ActuallyAutistics who are also into programming. Can you handle #RegEx / #RegExp?

Up to how much complexity?

When I was younger, it was easy. Today, I have to use a test tool! ^_^;;

#Autistics #Autism #ActuallyAutistic #Autistic #AutismSpectrum #AskingAutistics

@autistics @actuallyautistic

nis,
@nis@mstdn.dk avatar

@youronlyone @autistics @actuallyautistic
Anything other than '.' and parantheses, I have to google.

youronlyone,
@youronlyone@c.im avatar

@RoundSparrow I understand that, I don't like memorisation because I'm bad with it. I'm more of, the more I use it, the more I'll remember it, not because I memorised it.

Another thing (although off-topic), the castle memory technique, usually attributed to memorisation. But, I don't know, for me, it's a storage technique. If I don't pull out a memory from its storage, I won't even remember it.

@autistics @actuallyautistic

  • All
  • Subscribed
  • Moderated
  • Favorites
  • RegEx
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines