Are there Regular Expressions in TD?

Discussion forum about all things Gupta, OpenText and the community.
Msay

Are there Regular Expressions in TD?

Post by Msay » 18 Mar 2014, 16:32

Hi,
are regular expressions possible in the Team Developer?
The In-Build-Help does have an article about them, so I'd suppose it is. But how can I use them?
Does anyone have experience with them? Can I use them with f.ex. SalStrScan() ? If so, how to I tell TD it's a RegEx?
I need them for searching within strings and also for replacing. Regular expressions are so useful, I really hope they are usable!

Thanks for any help!

P.S. I use TD 6.1 right now but we will upgrade to TD 6.2 at some time.

Msay

Re: Are there Regular Expressions in TD?

Post by Msay » 10 Apr 2014, 08:37

Hi,
well it seems that no one has ever used Regex in TD.
So there might be another way to execute advanced string search/replacements?
So if I f.exp. search for a 4 character long string starting with "abc" and then following either a 1, a 2 or a 3 would it be

If SalStrScan( sTmp, 'abc') = 0 AND SalStrLength(sTmp) = 4 AND ( SalStrScan( sTmp, '1') = 3 OR SalStrScan( sTmp, '2') = 3 OR SalStrScan( sTmp, '3') = 3)

Any idea how to do it shorter?

And what if not a number but another letter might follow, but NOT a number? Do I have to give 24 choices (respective 10 negative choices for numbers)?
I've seen you can use _ for any character (% for any number of characters), but how to distinguish between number and letters? There should be a way, shouldn't there?

Thanks a lot for any input!

Didiman
Germany
Posts: 279
Joined: 21 Mar 2017, 13:05
Location: Bremen, Germany

Re: Are there Regular Expressions in TD?

Post by Didiman » 10 Apr 2014, 09:43

AFAIK there is no build in RegEx in TD. As we're using Oracle as RDBMS, I'm sometimes using SQL for this kind of problems. Maybe thsi might be a way for your Problem.

Greetz

--Andreas

clemdoc
Austria
Posts: 225
Joined: 08 Mar 2017, 09:51
Location: Austria

Re: Are there Regular Expressions in TD?

Post by clemdoc » 10 Apr 2014, 09:44

Hi!
Msay wrote:Hi,
well it seems that no one has ever used Regex in TD.
You can use VBScript RegExp (article from 1999, partly hilarious) via COM if you want to, but I don't know how fast this is.
As we don't use TD 6, I don't know what's possible in regard to .Net, where you can use System.Text.RegularExpressions.
And of course, you can always write a wrapper using C.

hth, ymmv, hand
clem

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3392
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Are there Regular Expressions in TD?

Post by Dave Rabelink » 10 Apr 2014, 12:04

You can use the Microsoft RegEx class.

An example here:

https://samples.tdcommunity.net/index ... rch_mode=f

(It is created in TD1.5, but it will show how to do it)
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Msay

Re: Are there Regular Expressions in TD?

Post by Msay » 11 Apr 2014, 14:55

Thanks a lot for all those suggestions!
Writing a wrapper in c doesn't sound like my expertise (haven't done it so far), so I'll skip that one.
But I'll definitely have a throughout look at the other things. (Though SQL is rarely an option.)
I haven't used any .NET so far, but this regex class seems pretty promising :)

And the sample Dave posted is great. I'm not very experienced at including foreign stuff, so having a complete example (thus old) is very helpful.
Thanks a lot to you two, Dave & Clem!

Oh I get so excited about being able to use regex :D

Cheers!

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 2 guests