RegExpBuilder – Create regular expressions using chained methods
11–20 of 56 posts
Re: RegExpBuilder – Create regular expressions using chained methods
#12Looks like Linq (from .Net/C#). Pretty sexy way to write Regular Expressions if you ask me. I've "learned" regular expressions multiple times but it just never sticks, I have no idea why. It certainly doesn't help that there are several different incompatible syntaxes (so what I remember and think "should" work doesn't). I'd prefer to write RegX's in this style, however I would pay attention to performance (not that…
Modern regular expression engines in a lot of languages, actually go beyond the expressiveness of a regular language. This is what damages performance.
There is no reason why this would reduce performance... if its not doing anything crazy.
If anything your taking work away from it. Your building the tree directly here, where as parser would normally build a tree from the string. But since this is integrating into the languages RE library i'm guessing its writing that tree as a string, which is then passed into the regular expression engine, to be turned into a tree again :)
Re: RegExpBuilder – Create regular expressions using chained methods
#13Generally, I find that if one's regexes are so complex that one needs visualizers or other aids in writing them, one doesn't have a regex problem, but a parsing problem. The method of parsing by recursive descent can often lead to much more understandable (if more verbose) "pattern matching".
Regex may be ugly, but you lose something important when you move from declarative to imperative.
Re: RegExpBuilder – Create regular expressions using chained methods
#14Thanks, this is a lot better than writing this (even if the formatting worked here): ``` (?xi) \b ( # Capture 1: entire matched URL (?: [a-z][\w-]+: # URL protocol and colon (?: /{1,3} # 1-3 slashes | # or [a-z0-9%] # Single letter or digit or '%' # (Trying not to match e.g. "URI::Escape") ) | # or www\d{0,3}[.] # "www.", "www1.", "www2." … "www999." | # or [a-z0-9.\-]+[.][a-z]{2,4}/ # looks like domain name followed…
/{1,3} # 1-3 slashes
| # or
[a-z0-9%] # Single letter or digit or "%";Re: RegExpBuilder – Create regular expressions using chained methods
#15Looks like Linq (from .Net/C#). Pretty sexy way to write Regular Expressions if you ask me. I've "learned" regular expressions multiple times but it just never sticks, I have no idea why. It certainly doesn't help that there are several different incompatible syntaxes (so what I remember and think "should" work doesn't). I'd prefer to write RegX's in this style, however I would pay attention to performance (not that…
Re: RegExpBuilder – Create regular expressions using chained methods
#16Looks like Linq (from .Net/C#). Pretty sexy way to write Regular Expressions if you ask me. I've "learned" regular expressions multiple times but it just never sticks, I have no idea why. It certainly doesn't help that there are several different incompatible syntaxes (so what I remember and think "should" work doesn't). I'd prefer to write RegX's in this style, however I would pay attention to performance (not that…
Regular expressions are high performance if you use automata style(Regular Language) regular expressions, which limits the use of some of the features you can use. Modern regular expression engines in a lot of languages, actually go beyond the expressiveness of a regular language. This is what damages performance. There is no reason why this would reduce performance... if its not doing anything crazy. If anything you…
If a regular expression runs too often, even pre-compiled (as they should be), you'll want to replace them with code written in the native language. I've gone in and replaced a one line search/replace written in RegX (compiled), with just a C-style for() loop over the wchar array, and had the memory usage drop by near 80% and performance increase by over 60%.
So high performance is all relative. However RegX isn't something I'd describe that way, even compiled. It is a nice way to write complex string parsing code quickly however.
Re: RegExpBuilder – Create regular expressions using chained methods
#17Looks like Linq (from .Net/C#). Pretty sexy way to write Regular Expressions if you ask me. I've "learned" regular expressions multiple times but it just never sticks, I have no idea why. It certainly doesn't help that there are several different incompatible syntaxes (so what I remember and think "should" work doesn't). I'd prefer to write RegX's in this style, however I would pay attention to performance (not that…
As the name suggests though, the focus was on passphrase criteria and it wasn't to produce a DSL for general regex building. The library also supports named templates and a few utility methods.
Re: RegExpBuilder – Create regular expressions using chained methods
#18#dumb
Re: RegExpBuilder – Create regular expressions using chained methods
#19Earlier quoted context omitted.
Regular expressions are high performance if you use automata style(Regular Language) regular expressions, which limits the use of some of the features you can use. Modern regular expression engines in a lot of languages, actually go beyond the expressiveness of a regular language. This is what damages performance. There is no reason why this would reduce performance... if its not doing anything crazy. If anything you…
I guess it depends on your definition of "high performance." If a regular expression runs too often, even pre-compiled (as they should be), you'll want to replace them with code written in the native language. I've gone in and replaced a one line search/replace written in RegX (compiled), with just a C-style for() loop over the wchar array, and had the memory usage drop by near 80% and performance increase by over 60…
It is highly dependent on the regular expression engine you use, most don't use automata because of extra features.
Re: RegExpBuilder – Create regular expressions using chained methods
#20Earlier quoted context omitted.
Regular expressions are high performance if you use automata style(Regular Language) regular expressions, which limits the use of some of the features you can use. Modern regular expression engines in a lot of languages, actually go beyond the expressiveness of a regular language. This is what damages performance. There is no reason why this would reduce performance... if its not doing anything crazy. If anything you…
I guess it depends on your definition of "high performance." If a regular expression runs too often, even pre-compiled (as they should be), you'll want to replace them with code written in the native language. I've gone in and replaced a one line search/replace written in RegX (compiled), with just a C-style for() loop over the wchar array, and had the memory usage drop by near 80% and performance increase by over 60…
If your regex is complicated, it will probably beat any naive attempt to write it into conventional string processing, short of reimplementing regexs in the first place. Especially since in many languages, "conventional string processing" may involve the creation of lots of copies and sub-copies.