T
Tim Conner
Hi,
Thanks to Peter, Chris and Steven who answered my previous answer about
regex to split a string. Actually, it was as easy as create a regex with the
pattern "/*-+()," and most of my string was splitted.
I am fascinated to the powerfull use of this RegEx class, so I wonder if it
could go a step further.
As a question, can regex be used to valid a set of different functions ?
Example : Suppose I have to verify the correctness of an input string, which
may contains one or more of the following functions :
Round ( NumericValue, Decimals)
Lower( StringValue )
Upper( StringValue )
Abs(NumericValue)
.... it will be like 15 functions, but let's name just this three.
Note : I just want to validate the input, I don't pretend to perform the
resolving part of this functions, just validate the input in terms of :
1.- Data type of parameters.
2.- Pairing parenthesis.
(the resolution of the of the functions will be done by 3rd party's code).
So, if I receive :
Abs("VB is great").
I would reject that sentense due the characters between parenthesis are a
string, not numeric values.
But, instead if I receive :
Upper( "C# is the best thing since sliced bread")
I would accept the sentence because the parameter is of the proper type.
Also:
Round( 1234.56, 2
would be invalid, due the missing parenthesis.
Finally, the functions can be nested.
So, the question is : can Regex handle this ? or should I start to go for
the parsers libraries ?
Thanks in advance,
Thanks to Peter, Chris and Steven who answered my previous answer about
regex to split a string. Actually, it was as easy as create a regex with the
pattern "/*-+()," and most of my string was splitted.
I am fascinated to the powerfull use of this RegEx class, so I wonder if it
could go a step further.
As a question, can regex be used to valid a set of different functions ?
Example : Suppose I have to verify the correctness of an input string, which
may contains one or more of the following functions :
Round ( NumericValue, Decimals)
Lower( StringValue )
Upper( StringValue )
Abs(NumericValue)
.... it will be like 15 functions, but let's name just this three.
Note : I just want to validate the input, I don't pretend to perform the
resolving part of this functions, just validate the input in terms of :
1.- Data type of parameters.
2.- Pairing parenthesis.
(the resolution of the of the functions will be done by 3rd party's code).
So, if I receive :
Abs("VB is great").
I would reject that sentense due the characters between parenthesis are a
string, not numeric values.
But, instead if I receive :
Upper( "C# is the best thing since sliced bread")
I would accept the sentence because the parameter is of the proper type.
Also:
Round( 1234.56, 2
would be invalid, due the missing parenthesis.
Finally, the functions can be nested.
So, the question is : can Regex handle this ? or should I start to go for
the parsers libraries ?
Thanks in advance,