Regular Expression

For questions and postings not covered by the other forums
davidmellow
Posts: 42
Joined: Thu Aug 27, 2009 1:27 pm
Location: New Plymouth, New Zealand

Regular Expression

Postby davidmellow » Thu Aug 27, 2009 1:37 pm

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?

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: Regular Expression

Postby allistar » Thu Aug 27, 2009 2:25 pm

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.

User avatar
jadeloveslave
Posts: 4
Joined: Wed Jun 24, 2009 7:20 am

Re: Regular Expression

Postby jadeloveslave » Thu Aug 27, 2009 10:18 pm

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. :idea:

jls.

Dennis
Posts: 10
Joined: Mon Aug 31, 2009 10:15 am
Location: New Plymouth

Re: Regular Expression

Postby Dennis » Mon Aug 31, 2009 10:22 am

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.

davidmellow
Posts: 42
Joined: Thu Aug 27, 2009 1:27 pm
Location: New Plymouth, New Zealand

Re: Regular Expression

Postby davidmellow » Wed Sep 02, 2009 4:27 pm

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.

User avatar
Dr Danyo
Posts: 56
Joined: Fri Aug 21, 2009 8:59 am

Re: Regular Expression

Postby Dr Danyo » Thu Apr 28, 2011 4:00 am

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.

davidmellow
Posts: 42
Joined: Thu Aug 27, 2009 1:27 pm
Location: New Plymouth, New Zealand

Re: Regular Expression

Postby davidmellow » Fri Apr 29, 2011 9:31 am

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.

User avatar
Dr Danyo
Posts: 56
Joined: Fri Aug 21, 2009 8:59 am

Re: Regular Expression

Postby Dr Danyo » Tue May 03, 2011 7:56 pm

Cheers David, sounds like a .net class library is the way to go.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests