Page 1 of 1
Regular Expression
Posted: Thu Aug 27, 2009 1:37 pm
by davidmellow
I don't recall ever seeing it, but are there any inbuilt regular expression handling (pattern matching etc) functions in Jade?
Usually I avoid even looking at regular expressions on account of the psychological trauma it causes, but I admit they are sometimes useful and they would be right now.
Have I missed seeing such functions in Jade?
Re: Regular Expression
Posted: Thu Aug 27, 2009 2:25 pm
by allistar
There are no built in functions in Jade. If you want to use regular expressions to see if a single piece of text matches the regex, then you should be able to link to an external function that provides regex capabilities. If you want to use it to find all objects that have a property that match a regex (i.e. a query over a collection) then you could still use an external function call, but it wouldn't be optimised to take into account dictionary keys etc. You'd have to call it on every instance in the collection. Short of relying on an SQL view of the database, you could code in optimisations yourself. Doing this on standard regex syntax though would cause pychological trauma as you have mentioned.
Re: Regular Expression
Posted: Thu Aug 27, 2009 10:18 pm
by jadeloveslave
The JadeEditMask control must use some form of RegEx. Are you looking to validate user input ?
Otherwise Allistar's external function approach sounds like the way to go. You could even wrap it up and release it as a new JadeRegEx class for the rest of us to use.
jls.
Re: Regular Expression
Posted: Mon Aug 31, 2009 10:22 am
by Dennis
I found the Microsoft VBScript Regular Expressions ActiveX quite useful.
If you are using Linux or want to use a DLL then there are quite a few alternatives such as PCRE (Perl compatible Regular Expressions) but then you will have to write your own class wrapper.
Re: Regular Expression
Posted: Wed Sep 02, 2009 4:27 pm
by davidmellow
Thanks for your suggestions all, just wanted to make sure I wasn't missing any inbuilt function and you've verified what I suspected. Cheers.
Re: Regular Expression
Posted: Thu Apr 28, 2011 4:00 am
by Dr Danyo
Hi David,
Are you able to share what your final solution with regular expressions and JADE was?
I'm curious to know if its a valid candidate for our input data validation. cheers.
Dr Danyo.
Re: Regular Expression
Posted: Fri Apr 29, 2011 9:31 am
by davidmellow
Hi drdanyo, the specific use we might have had for this didn't seem to warrant pursuing it at the time (it was simply something, validating format of email addresses typed in by users, that I probably would have done if Jade had its own regex engine).
Out of curiosity last night I did create a .NET assembly exposing a couple of very trivial methods to validate a match, imported it into JAde and it seemed to work fine. (The relevant namespace is System.Text.RegularExpressions in the System.dll assembly).
An aside, googling for patterns to validate email addresses in itself proved interesting, as to the bewildering raft of solutions people had come up with and tested, some of them surprisingly complex. It was not as trivial as I may have thought, depending on the level of accuracy one requires.
Re: Regular Expression
Posted: Tue May 03, 2011 7:56 pm
by Dr Danyo
Cheers David, sounds like a .net class library is the way to go.