Skip to main content

Posts

Showing posts with the label regex

GPT For Regex - Pros And Cons

  RegExGPT is a online playground that lets you enter a source  and a target string to let GPT generate the regular expression for a match. But what are the pros and cons of the GPT approach to regex code generation? Despite their power, regular expressions come with their own challenges; they have a tendency to quickly become unreadable so that understanding them becomes a matter of deobfuscation as well as learning how to use them involves a steep curve. https://www.i-programmer.info/news/105-artificial-intelligence/16321-gpt-for-regex-pros-and-cons.html

RegexLearn And Other RegEx Resources

 RegexLearn is an intuitive online instruction led playground where you get to learn how to construct regular expressions. We also revisit other tools, advanced regex constructs, regex programming language portability and how to deter Regular expression Denial of Service attacks. full article on i=programmer: https://www.i-programmer.info/news/90-tools/15067-regexlearn-and-other-regex-resources.html

Regexploit - Put A Stop To Regular Expression DoS Attacks

  There's a new tool that can identify resource-hungry regular expressions that can be potentially exploited in launching ReDos attacks. In  Can Regular Expressions Be Safely Reused Across Languages?  I looked into whether it is possible to reuse a regular expression crafted in JavaScript verbatim in Python. Would doing so lead to the same results and performance? Swap your languages of interest in place of JavaScript and Python; the question remains the same. Setting aside the question of equality of the cross-language results, the article also looked at the performance side of the story which perfectly relates to this Regxploit tale. full article on i-programmer

Can Regular Expressions Be Safely Reused Across Languages?

That is, can I reuse a regular expression crafted in JavaScript verbatim in Python? In doing so, will I get the same results and performance? Enter your languages of interest in place of JavaScript and Python, the question remains the same.  It is a not well kept secret that programmers are huge fans of copying and pasting code snippets, regular expressions included, that are freely available across the web. But unlike copying and pasting code within the boundaries of the same programming language, does copying a regular expression that was crafted in one language into another work as assumed, or would it introduce errors, both semantically and in performance? "Why Aren’t Regular Expressions a Lingua Franca? An Empirical Study on the Re-use and Portability of Regular Expressions"  is a paper that attempts to shed light on the question: are regular expressions truly portable? full article on i-programmer.info

"Parsing with Perl 6 Regexes and Grammars" mega book review

This is Moritz Lenz's second book release. One could argue that you  have to tackle the first one, "Perl 6 Fundamentals" before progressing to this one. This is not the case, however, as the book is written in such a way that it can be consumed independently without requiring any kind of knowledge in Perl 6.Saying that, it does however dedicate a chapter to getting started with Per l 6, just enough to ready you to work with its regular expressions.That aside, the author does indeed go into detail explaining the Perl 6 features used in the examples. A question that I also posed to Moritz was whether the knowledge obtained from studying this book is transferable to Perl5 or to other languages, or, is it rather unique to Perl6? Moritz's reply was that the general skills/knowledge is transferable, but p6 regexes and grammars offer much awesome stuff that other implementations simply don't have. So while the material is only applicable to Perl 6, since its imp...

Taming Regular Expressions

Despite their power, regular expressions come with their own challenges. First of all, they have a tendency to quickly become unreadable, so that understanding them becomes a matter of deobfuscation. Furthermore learning how to use them involves a steep curve as they've always been difficult to master. Simple Regex Language, is the latest addition to the many solutions already at large. An open source project on GitHub, under the MIT License, it takes the radical approach of targeting the very "language" that we use to write regular expressions, completely replacing it with a domain specific counterpart. But first, let's take a deeper look into the domain specific problem that SRL tries to alleviate. To address the primary issue of unreadability, the /x modifier was introduced, which allowed for the inclusion of white space, line breaks as well as commenting in the regex itself. Under /x the regex engine wouldn't treat those elements as part of th...

Machine Learning Lab's Regular Expression Game

Machine Learning Lab has created a game that puts your regular expression skills to the test. We first met  Machine Learning Lab in  Automatically Generating Regular Expressions with Genetic Programming , when we used its RegexGenerator++. Now we are back to explore how to have fun with it. The game comprises of 12 levels of increasing difficulty, with each level containing a different block of text, which in turn contains the parts of the text that must be matched against a regular expression - which has to supplied by the user. Each attempt is timed and rated in a  'F-measure' scale that measures how close the extractions and the matches were, with 100 points being awarded for the perfect result, 0 for a totally wrong one or for giving up.  Before the game begins you complete a simple questionnaire where you have to tick the boxes adjacent to the regular expression constructs you are familiar with. full article on i-programmer.info

Automatically Generating Regular Expressions with Genetic Programming

Is it possible to "breed" a correct regular expression so that you don't have to go to the trouble of actually working it out for yourself? The answer seems to be "yes", and the result could even be better than the one you created by hard logical thinking. When you construct a computer program you do so through a series of well defined instructions that work on a set of data and produce a desired outcome. Given our focus here is on regular expressions, let's say that our goal is to match just the alphanumeric characters of the string:   'http://www.google.com' . Sticking to the traditional way we would have to supply an instruction in the form of a regular expression, that is '/[a-zA-Z]/g' But what if we could start the other way around? That is, get the computer to solve problems without being explicitly programmed? How can this be done? With Genetic Programming we can tell a computer program what we're after and let ...

Advanced Perl Regular Expressions - The Pattern Code Expression

In this part of our series exploring Perl RegEx we are going to look into another advanced construct, that of the pattern code expression ??{code} . According to the official perldoc this  "..is like a regular code expression, except that the result of the code evaluation is treated as a regular expression and matched immediately." We will also attempt to combine it with the ?{code} code evaluation expression, covered in the first part of the series. We'll build on the same scenario, in which we were receiving a serialized stream from a web service that had all special characters encoded in HTML entity hex encoding. The requirement was to convert them back to their actual character representation, for example ' £ ' would become the pound £ symbol). Additionally we are going to search for files that contain the decoded string in their names. read full article on i-programmer

Advanced Perl Regular Expressions - Extended Constructs

Perl is still the leader, almost the standard, when it comes to regular expressions. However it also possesses some lesser known features that  deserve special attention, like the embedded code constructs for runtime code evaluation. Let's find out what Perl regular expressions are really like with Perl inside. How does Perl let you mix code and regular expressions? It provides the  (?{ code })  construct which essentially allows for embedding Perl code that gets executed upon every match of the pattern, inside the regular expression. For example, let's say we have a file that is about to be distributed to multiple platforms/Operating Systems therefore its file name needs to be portable and compatible with the various OSs' file systems. What is the best way to achieve this? full article on i-programmer

Perl's text handling to the rescue....

There was a very interesting proble set forward at the Ingres forum, quoting : "I have to use an Ingres Database to store my data which is in several languages (like french, german, and so on). In my web site, the user can use the function "search". The problem are the special characters like éàèâ in french, or öäü in german. The user doesn't enter these characters, but it should be found anyway. For example:   In the database is the word "château". The user types "chateau" (whithout â) The program should find the "château", even if "chateau" was typed. So all accents in the database should be replaced by something more useful (like "_")  Has someone an idea how to do that? Ingres database version : 9.2.1    Thanks a lot, Kakmael"  and this is my attempt to tackle it,using Perl,of course Ok you so you get the latin1 encoded string "Chateu" from your web form and you pa...