Using Regex with Smart Tags

Add-in Express™ Support Service
That's what is more important than anything else

Using Regex with Smart Tags
 
Gaston Quirque




Posts: 7
Joined: 2011-09-01
Hi,
I need to use regular expressions in a smart tag.

I've found this topic but I think is a bit old.

http://www.add-in-express.com/forum/read.php?FID=5&TID=1265&MID=5867#message5867
or
http://www.add-in-express.com/forum/read.php?FID=5&TID=4908


Unfortunately none of these topics explain how to add a Regex object to the ADXSmartTag object.

This is my recognize event:
private void adxSmartTag_Recognize(object sender, ADXSmartTagRecognizeEventArgs e)
{
adxSmartTag.????
...

Does anybody knows how to continue this story? :)

Thanks in advance,
Gaston
Posted 08 Sep, 2011 11:59:25 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Gaston,

Sure. You just need to have a basic knowledge of regular expressions (see the System.Text.RegularExpressions namespace in .net framework for more information). For example:

 private void adxSmartTag1_Recognize(object sender, ADXSmartTagRecognizeEventArgs e)
{
    System.Text.RegularExpressions.Regex regExp = new Regex(@"^(d{3})sd{3}-d{4}$");
    if (regExp.IsMatch(e.Text))
    {
        e.CommitProc(0, 2);
    }
}


Please read more about regular expressions in the Chapter 3: Strings and Regular Expressions and .NET Framework Regular Expressions article in MSDN.
.NET, Extended MAPI, Windows Phone & RT
Posted 09 Sep, 2011 02:02:19 Top
Gaston Quirque




Posts: 7
Joined: 2011-09-01
Hi Eugene,
thanks for your reply.

My problem was not the regular expressions...my problem was how to tell the adxSmartTag1_Recognize event "ey! I've found a match!"...

The answer is in this line of code: e.CommitProc(...) ;)

Thank you!

Regards,
Gaston
Posted 13 Sep, 2011 14:23:02 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
You are welcome, Gaston!
.NET, Extended MAPI, Windows Phone & RT
Posted 14 Sep, 2011 03:29:39 Top