dmnelson, to random
@dmnelson@mastodon.social avatar

I’ve had regular expressions on the mind lately. No idea why. But any time I see a string of text that clearly adheres to a standard (a serial, asset tag, etc.) I end up thinking about a regex that would validate it.

dmnelson,
@dmnelson@mastodon.social avatar

.*

These two characters contain limitless power. They are every book ever written. Every thought that has ever been conjured. Every joy and every regret. Every victory and every defeat. Every whisper between lovers. They are you, me, and all of human existence. Let us propel them into deep space so one day some distant future civilization might witness them and know all that is Us. #regex

c0dec0dec0de, to python
@c0dec0dec0de@hachyderm.io avatar

TIL about Python regex named capture groups and the groupdict() method of the Match class. So I guess I’ll be committing more regex crimes.
#python #regex

vwbusguy, to RegEx
@vwbusguy@mastodon.online avatar

Solved a *problem with #regex with more regex today.

*Not actually a problem with the regex itself, but one of unclear business requirements, but for anyone that said I'd regret the DNS regex I wrote a month later, I ate that soup today and it honestly wasn't bad.

anand7253, to programming

I'm still designing my language.

Why not just introduce RegExps into pointers?

int a; / nonnull pointer to single int */
int ?a; / can-be-null pointer to single int /
int +a; /
nonnull pointer to array begining */
int +?a;

Isn't using the nonnull attribute a bit long?

Now yes, I don't see the point of + and +?, but there is the 'array of unspecified length' syntax:
int *argv[];
so why not?

#programming #languageprogramming #c #pointers #regex #regexHumor #humor #becauseWhyNot

khalidabuhakmeh, to dotnet
@khalidabuhakmeh@mastodon.social avatar

The weird thing about Regex escaping is you only need to escape the first part of a valid Regex pair if you’re looking to use that character. For example, look at the following regex. #dotnet #regex

profoundlynerdy, to python
@profoundlynerdy@bitbang.social avatar

With #Python stealing everyone else's thunder, what makes a project a good fit for a scripting language OTHER than Python?

#Perl #Raku #Lua #Ruby #PHP #powershell #bash #programming

dboehmer,

@profoundlynerdy #Perl and even more #Rakulang have unmatched #regex capabilities and #Unicode support for text processing. You can match very special text patterns, especially regarding multiple languages or scripts.

Example: find all numbers in a text in Arabic, Roman, Chinese or some other form but not in mixed scripts and with at least 3 graphemes (not characters, not codepoints, not bytes)
@Perl

aeveltstra, (edited ) to random
@aeveltstra@mastodon.social avatar

ℛ𝒾ℊ𝒽𝓉. 𝒮ℴ. ℐ 𝓌𝒶𝓃𝓉ℯ𝒹 𝓉ℴ 𝓉𝓇𝓎 𝓉𝒽𝒾𝓈 𝒻ℴ𝓃𝓉-𝒸𝒽𝒶𝓃ℊ𝒾𝓃ℊ 𝓅𝒽ℴ𝓃ℯ 𝒶𝓅𝓅, 𝒶𝓃𝒹 𝓈ℯℯ 𝓌𝒽ℯ𝓉𝒽ℯ𝓇 𝒻ℴ𝓃𝓉𝓈 𝓈𝓉𝒶𝓎 𝒸𝒽𝒶𝓃ℊℯ𝒹 𝓌𝒽ℯ𝓃 𝓇ℯ𝒶𝒹𝒾𝓃ℊ 𝒶 𝓅ℴ𝓈𝓉 𝓊𝓈𝒾𝓃ℊ ℴ𝓉𝒽ℯ𝓇 𝒸𝓁𝒾ℯ𝓃𝓉𝓈 𝓉𝒽𝒶𝓃 𝓂𝓎 𝓅𝒽ℴ𝓃ℯ.

𝐈𝐭'𝐬 𝐚 𝐛𝐢𝐭 𝐰𝐞𝐢𝐫𝐝 𝐚𝐧𝐝 𝐈 𝐰𝗼𝐮𝐥𝐝 𝐥𝐢𝐤𝐞 𝐭𝗼 𝐤𝐧𝗼𝐰 𝐡𝗼𝐰 𝐢𝐭 𝐰𝗼𝐫𝐤𝐬. 𝐀𝐧𝐲 𝐬𝐮𝐠𝐠𝐞𝐬𝐭𝐢𝗼𝐧𝐬 𝗼𝐧 𝐡𝗼𝐰 𝐚𝐧 𝐚𝐩𝐩 𝐜𝐚𝐧 𝗺𝐚𝐤𝐞 𝗼𝐭𝐡𝐞𝐫 𝐥𝐞𝐭𝐭𝐞𝐫 𝐬𝐡𝐚𝐩𝐞𝐬 𝐚𝐩𝐩𝐞𝐚𝐫? 𝐈𝐬 𝐢𝐭, 𝐥𝐢𝐤𝐞, 𝐚 𝐬𝐩𝐞𝐜𝐢𝐚𝐥 𝐔𝐧𝐢𝐜𝗼𝐝𝐞 𝐬𝐮𝐛𝐫𝐚𝐧𝐠𝐞? 𝐋𝐞𝐭 𝗺𝐞 𝐤𝐧𝗼𝐰!

aeveltstra,
@aeveltstra@mastodon.social avatar

Yo, #regex peoples: if I use a filter /^[a-z]*/i does that include only the US-ASCII alphabet? Or does it include all letter-like glyphs of Unicode?

What regex do I need if I want to allow all letter-like Unicode characters, but not control characters?

Specifically asking for pass phrase input filtering and #slqinjection prevention.

#pentesting #cybersecurity

ctietze, to emacs
@ctietze@mastodon.social avatar

"Yes, can [absolutely!!] do this" https://www.youtube.com/shorts/U8-KM6WfzcU

Reply to a similar video, see the video description for a link.

It's about reformatting strings of text via interactively with a live preview of the result. visual-regexp.el to the rescue, this is quite nice in Emacs.

tantramar, to random
@tantramar@nojack.easydns.ca avatar

understanding regular expressions enough to get real work done with them is a double-edged sword: it’s a power verging on magic, but it also lures you down the time-suck/rabbit-hole. #regex #grep @bbedit

adamsdesk, (edited ) to Bash
@adamsdesk@fosstodon.org avatar

I must have my thoughts crossed as for the life of me I can't seem to figure out this regex in BASH using a parameter expansion.

I want to search for 2 or more dashes and then replace with one dash. Here is what I thought would work, but doesn't. Any suggestions?

string="Hello-World! command---line"
string="${title//[-]{2,}/-}"

categulario, to RegEx Spanish
@categulario@mstdn.mx avatar

Acabo de desperdiciar una oportunidad única de mostrar las capacidades de la #InteligenciaArtificial

mandaron un mensaje a un grupo de #whatsapp que decía "a las 9?" a lo cual la respuesta automática ofrecida por la IA fue: "sí, a las 3".

yo podría haber hecho eso mejor con puro #regex (y de hecho lo hice una vez...)

themeowcate, to RegEx French
@themeowcate@piaille.fr avatar

#Dev #Code

Mon N+1 : "J'aurais besoin de comprendre. Je t'avais transmis ce gros fichier de données toutes bordéliques régurgitées et tu as fourni un CSV tout propre classé et filtré, tu pourrais me passer le script que tu avais utilisé pour faire ça ?"

Moi : "Ah mais j'ai pas de script."

Lui : "Mais comment tu as fait ça ?"

Moi, tout fier : "C'est le pouvoir de la REGEX !"

J'adore les regex. Ça résout tout, les regex ! Tiens, je sais, je vais faire un parser HTML en regex !

#regex

vwbusguy, to Starwars
@vwbusguy@mastodon.online avatar

This was a fun one! #StarWars #regex

vwbusguy,
@vwbusguy@mastodon.online avatar

And this #regex puzzle is song lyrics!

outofcontrol, to RegEx
@outofcontrol@phpc.social avatar

Oh this is awesome! Finally a crossword my wife can’t finish when I’m not looking. Have done a couple of dozen, a good regex test!

#regex https://mastodon.online/@vwbusguy/111229121766072458

vwbusguy, to RegEx
@vwbusguy@mastodon.online avatar

The thing about coding with is that it feels like I'm getting paid to do Sudoku puzzles for a living.

Tip for those who are asked to review code with regex: Rather than focusing on the regex itself, ask to see the automated tests that it is ran against and look for gaps in the tests rather than getting lost in the weeds with scrutinizing the regex itself unless there's an obvious significant performance problem.

vwbusguy,
@vwbusguy@mastodon.online avatar

Like any tech, #regex feels like black magic until you understand it.

vwbusguy,
@vwbusguy@mastodon.online avatar

If you feel like you don't yet understand #regex as well as you would like, I recommend this website for practicing/learning it:

https://regexcrossword.com

vwbusguy,
@vwbusguy@mastodon.online avatar

@jgillich Saying you won't ever learn/use #regex is like saying "I refuse to learn how to drive a stick shift", which might get to you to pass a driver's test, but it's going to be awkward some day when you need to borrow a car to get somewhere and it's a stick and now you have to try to figure out then and there how not to burn out someone else's clutch.

barubary,

@vwbusguy My advice is essentially the opposite. Focus on the #regex, at least to get started. Regexes are code. Just like any other programming language, you have to learn the syntax and practice a bit, but the same principles apply as with program code in general.

When reviewing code, start by reading it. If there's something unclear, ask about it. Don't accept a regex consisting of 100 characters in one line without a single space. Compared to most other languages, regex syntax is terse: Few (if any) keywords, lots of symbols. Divide complex regexes into simple parts that are assembled into bigger constructs. You probably wouldn't accept a patch that adds hundreds of lines of unfactored code that has complex logic and nested loops, but no indentation or whitespace and no functions, so why write your regexes this way?

If your language builds regexes from strings, use string concatenation, formatting/indentation, comments, and named variables to make the structure of the pattern clear. If your language has the /x modifier, use it to allow sensible formatting and comments right in the regex (remember to escape with `` or [ ] any spaces that should match literally). If your language supports (?(DEFINE)...) and the (?&foo) syntax for named "regex subroutines", consider using it (but also consider restructuring your code: it might be trying to do too much in a single regex).

Once you understand the structure of the regex and how it is meant to work, it becomes much easier to review the tests: Are there any? Do they cover every input variant, exercising all parts of the regex, both matching and failing? (Failing matches are also relevant for finding performance issues: If a regex finds a match, it usually does so quickly. But a regex with exponential backtracking can take forever to fail because it'll try a huge number of variations before giving up on a string that doesn't match.)

There is an infamous regex for RFC 822 email addresses out there on the internet[1]. It is thousands of characters long and utterly incomprehensible. However, it was not written manually: It is essentially "object code", assembled by commented code using string concatenation from named variables that follow the structure of the BNF grammar in the RFC. Strive for the latter, not the former.

[1] http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

vwbusguy, to ruby
@vwbusguy@mastodon.online avatar

These are the two lines of code (minus some constants and file operations) that saved me a while lot of tediousness, today... #ruby #regex #programming #Jenkins

It ended up being a bit more involved than my post earlier, but was able to script it to automate the patching and PRs. It looks terrible, but I'm pretty happy with the end result.

vwbusguy, (edited ) to ruby
@vwbusguy@mastodon.online avatar

Some have said that I am capable of writing in any language. Behold my .

mjgardner,
@mjgardner@social.sdf.org avatar

@vwbusguy @barubary
@Perl I’m glad https://mastodon.online/@vwbusguy/111212516938547685 works for you, but I feel pity for when you come back to it later.

It’s nothing to do with and everything to do with shitty possible in almost any language.

Though it’s true that Perl’s reputation took a lot of damage from shitty developers filling the world with shitty in their shitty Perl code. So you’re in a big group, albeit via .

villares, to RegEx
@villares@ciberlandia.pt avatar

"I hate #regex, but I think this worked fine. I used #regexxer, a helper to find and replace stuff on multiple files, for those [of us] less well versed with the traditional CLI regex workflow."

Any other tips for user friendly find-and-replace tools?

https://github.com/py5coding/py5generator/issues/350#issuecomment-1752025818 #Python #py5

Colarusso, to RegEx
@Colarusso@mastodon.social avatar

Geekery Notice: RegEx!!!

In addition to being an open source client-side RSS reader with an algo-driven timeline that keeps your votes and searches on your device, https://myrssalgo.org just added a bunch of RegEx¹ functionality.

Yes, there’s a RegEx-enabled search, but wait for it… now you can use RegEx to promote and mute content in your timeline—the dream is real!


¹ https://www.codingthelaw.org/Fall_2020/level/5/#intro_vid

#SuffolkRSSalgo #RegEx #RSS #FOSS

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