Regexes rely on the idea of finding information which is all on the one line. If you can figure out how to insert carriage returns at regular intervals, finding and extracting what you need becomes much easier, than just using a regex.
People will criticise me here because I'm making the computer perform multiple steps, whereas a regex looks like it's performing just one; but in reality with a regex, the user is performing the multiple steps inside their own head first, in order to design it. This way is easier.
Practice every single day. Or be like me and get a pretty good grip on the basics for one personal project. Then a few months later you find a problem that would be elegantly solved with regex. But decide to use a bunch of if/then/else statements because you forgot everything and are too lazy to go back to the previous project to see what the heck you did.
Practice with powershell on windows or perl on linux.
Dont use grep or sed, both of those are gay as fuck and have gimped regex parsing unless you call them with extended support arg (-E), and even then they support barely any features.
perl is the god of regex, and powershell implements PCRE, so it's great for practicing if you're on windows.
If you want to get good, you need to learn them using perl. You just need to know how to write basic hello world first and then start going through the regular expression tutorial https://perldoc.perl.org/perlretut
go to regexr.com and practice, it's pretty great.
one thing to keep in mind is that a regex pattern is like its own shorthand language
slashes / / contain the pattern
the flag / /g means find the pattern as many times at it appears in the string
the pattern itself can be a plain word, or symbols or ranges, for example
/fag/ will find the first instance of the sequence of letters 'fag'
/fag/g will find all the instances of the sequence of letters 'fag'
another thing to keep in mind is that a regex pattern on it's own does nothing, it's meant to be used with a function and most of it's use cases are with a string method.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
LULZ boards will run middleware on posts using regexes, like if they wanted to censor the word fag and replace it with pony they would do something like
preparedPost = submittedPost.replace(/fag/ig, "pony") the i flag means case insensitive.
Who cares? I had to learn regular expressions for a logic course, but in day-to-day tasks like programming, you can easily ask ChatGPT or search Stack Overflow.
Get kodi and batch rename your anime library to work with it.
Use Emacs Wdired Mode.
Done.
you don't
indians write them for free on stackoverflow
Start with grep.
Commodore 64s are such trash. BBC Micro was better.
Kek nice troll
now compare BBC versions of Elite versus C64. then start crying.
chat gpt 4 is still out you know
Old xoomer proverb
>write regex to solve problem, now have two problem
Don't bother.
echo "[email protected]" | tr '@' 'n' > file
sed -n '2p' file | sed s'@test2@hello@' > file2
cat file2 | tr 'n' '@' > file
Regexes rely on the idea of finding information which is all on the one line. If you can figure out how to insert carriage returns at regular intervals, finding and extracting what you need becomes much easier, than just using a regex.
People will criticise me here because I'm making the computer perform multiple steps, whereas a regex looks like it's performing just one; but in reality with a regex, the user is performing the multiple steps inside their own head first, in order to design it. This way is easier.
Practice every single day. Or be like me and get a pretty good grip on the basics for one personal project. Then a few months later you find a problem that would be elegantly solved with regex. But decide to use a bunch of if/then/else statements because you forgot everything and are too lazy to go back to the previous project to see what the heck you did.
Practice with powershell on windows or perl on linux.
Dont use grep or sed, both of those are gay as fuck and have gimped regex parsing unless you call them with extended support arg (-E), and even then they support barely any features.
perl is the god of regex, and powershell implements PCRE, so it's great for practicing if you're on windows.
Practice
now I want to go experience q-link as it originally was 🙁
?t=72
Practice makes perfect, it's really the only solution.
It healps to search for real world problems and solve them as exercises.
If you want to get good, you need to learn them using perl. You just need to know how to write basic hello world first and then start going through the regular expression tutorial https://perldoc.perl.org/perlretut
isn't it raku now?
use a code editor where find and replace are done with regex by default. like vim
C64 - nice!
Get a job writing parsers for a SOC that ingests logs of all the shittest tier network devices known to man.
write a nano syntax highlighting file for some programming language
go to regexr.com and practice, it's pretty great.
one thing to keep in mind is that a regex pattern is like its own shorthand language
slashes / / contain the pattern
the flag / /g means find the pattern as many times at it appears in the string
the pattern itself can be a plain word, or symbols or ranges, for example
/fag/ will find the first instance of the sequence of letters 'fag'
/fag/g will find all the instances of the sequence of letters 'fag'
another thing to keep in mind is that a regex pattern on it's own does nothing, it's meant to be used with a function and most of it's use cases are with a string method.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
LULZ boards will run middleware on posts using regexes, like if they wanted to censor the word fag and replace it with pony they would do something like
preparedPost = submittedPost.replace(/fag/ig, "pony") the i flag means case insensitive.
Who cares? I had to learn regular expressions for a logic course, but in day-to-day tasks like programming, you can easily ask ChatGPT or search Stack Overflow.