|
I mostly use it when writing bash scripts and need to search or replace some text that may or may not contain variable characters or digits or words (etc.). RegEx is mostly useful for pattern matching and so it's a pretty irreplaceable tool for programmers. I have a script for instance that grabs a list of youtube video IDs via the gdata.youtube api to be downloaded by youtube-dl (a python script/application). I like my stuff to be automatically organized so I put the list of IDs in an already made folder for that playlist. To name the folder I grab the html the api produces for my script and then run it through with 'grep -o "<title>.*</title>"' where it searches for the html title element tags and then I can format that text in between the tags to be used for my folder name. The same concept gets reused for finding the video ID tags too. And despite my usage, it can be built the same way if you wanted to build an Android/iOS app that searched youtube for videos. I tend to mostly write scripts that make use of the wildcard (.* for instance, which will select any characters for as many times before it reaches the end) features of regex, but if I were managing a database or search engine or some other high variable data, there are all sorts of possible uses for regex. |
