Vasanth Arivali's Blog

Using Regular Expression in Ax 2009

Posted on: April 21, 2011

Hi Guys,

Here i posted a small job , to explain how we use regular expressin in Axapta. Try it.

static void RegularExpression_Test()

{

int nameLength,myStringLength;

str myname = “Vasanth”;

str myString = “1234”;

str formatString , formatString1;

System.Text.RegularExpressions.Regex regEx;

System.Text.RegularExpressions.Regex regEx1;

System.Text.RegularExpressions.Match regMatch;

InteropPermission permission = new InteropPermission(InteropKind::ClrInterop);

boolean retVal, retVal1;

;

nameLength = strLen(myname);

myStringLength = strLen(myString);

formatString   = strfmt(@”^[0-9]{%1}”, myStringLength);

formatString1   = strfmt(@”^[a-zA-Z ]{%1}”, nameLength);

permission.assert();

//BP Deviation documented

regEx = new System.Text.RegularExpression.Regex(formatString);

regEx1 = new System.Text.RegularExpression.Regex(formatString1);

regMatch = regEx.Match(myString);

retVal = regMatch.get_Success();

print retVal; // Returns True;

regMatch = regEx1.Match(myname);

retVal1 = regMatch.get_Success();

print retVal1 // Returns True;


}

Thanks & Regards,

Vasanth Arivali

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Welcome

What’s happening?

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Categories

Join 13 other followers

%d bloggers like this: