Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
ChuvaS3167yI fucking love regex. I love it so much that I have an android app of regex's crosswords
-
@Floydian It allows you for creating basic patterns for matching/splitting or extracting strings against/on/out of strings. Very useful and mostly easy to write but sometimes hard to read.
-
IcyTv1187y@Floydian regex is short for regular expression, as you said. It is a way to match a String, meaning you can figure out if the String has a desired format, without knowing the content of said String. I.E. you get a user input and you want to make sure they didn't start with a number and didn't use special characters, you can say that with regex (Don't ask me how though, regex is really hard!)
-
webnoob11027y@Floydian – The only use case I've ever come across for RegEx is for parsing sections of strings that follow a pattern defined by the dev (e.g., if a phonebook existed as a single string of names and numbers, RegEx could help you parse out these names and numbers to be more easily manipulated for later).
The hardest part for noobs like myself is being the dev that comes up with a pattern that doesn't suck. And today, I'm sucking at RegEx. -
hell165967y@webnoob we have a web app where you can perform queries against some data, something like:
column=value AND column2=value2
And endless combinations, we had to write a regex test to check if it is ok on the client side.
Its pretty cool, I love regex. -
dgfz397yIt's not that bad.
I used to feel the same way. But one day i just decided i want to learn it and spent the whole day reading tuts, making notes, doing examples and re reading my notes.
Make the investment. Just one day. -
dottedr1907y@Floydian regex is useful if you want for example: find all the words that start with letter 't' and finish with 'h' or some specific number format, postcode.
-
xewl41267yI have a love/hate relationship with it, but I'm mostly just doing it wrong when I hate it, and found a solution when I love it... (:
-
hashit11307yi had this problem to search for a given 2d array in another 2d array ..regex saved the day
-
Volbrite107yRegEx are great, but fucking annoying... Especially when tou have to create a regex to validate a date... :D
-
@Floydian
Regex is a pattern like:
^#?([a-f0-9]{6}|[a-f0-9]{3})$
which says:
^ start of the line
#? maybe an octothorpe?
() store this stuff for later
[] anything inside of this is fine
a-f0-9 hexadecimals ftw!
{6} the thing before repeats this often
| or... it could also be {3} hexadecimals
$ end of the line!
So the above matches #000, 32127a, and #0055cc, and returns the numbers inside of it.
1. Yes, this is powerful. You can match, check and extract parts of texts in pretty advances ways. Regexes are awesome to give instant validation feedback in web forms, to search and replace in an IDE, or filter important fields from a file.
2. Yes, it's complicated and fragile. Regex can give false results. People get lost, writing monster-regexes to validate html snippets or email accounts, because those are not very "regular" (http://ex-parrot.com/~pdw/...).
I love puzzling out good/simple regexes, but without regex101.com I would have turned insane by now.
Related Rants
Man. Fuck RegEx.
rant
regex