Page 1 of 1

RemoveRegularExpression() and others...

Posted: Mon Jul 28, 2008 6:56 pm
by AND51
Hello!

In this thread I would like to suggest some new RegularExpression-Functions.
They should work like the String-Library, but offer more comfortably due to their flexibility.


1.
It would be nice, if you can add a RemoveRegularExpression(), to have th e same harmony as ReplaceString() and RemoveString().

2.
Some kind of CountRegularExpression() would be extremly useful, too. I asked Fred, if he could make MatchRegularExpression() returning the number of matches. He rejected this with the words, "It's because of the performance." He is right, MatchRegExp should stay untouched.

3.
When thinking about 2), what do you think about a FindRegularExpression()? It should work just like FindString() and return the position of the searched string.

4.
Another important command I think would be GetSubString(). That means, if you have an expression like "abc\d*xyz" you might want to have the digits only (only a very simple example). But you cannot extract them directly, because you need "abc" and "xyz" to determine, *which* numbers you want.

Another example: How to get the META-Refresh tag from a website (e. g. the redirection page www.pure-board.de )?
You need to extract the refresh tag with "<meta name=refresh http-equiv=0;URL=.*>". Then you must manually cut the URL out. GetSubString() is useful here.

This was asked several times in this forum and edel posted a method, where he imports the RegExp-Library and uses some of its native functions. In my opinion, it would be very handy and more comfortable for all of us to have these commands natively in PB to avoid the Import-thing.

5.
Similar to 4) might be the idea of RegularExpressionField() as parallel to StringField() where as the expression represents the separator.



The overall idea is to accumulate the RegExp lib to the String lib.
I want to add, that I find idea 2 + 4 most important.
Thanks for reading! :)