Show/Hide Toolbars

EmEditor Help

Navigation: EmEditor Help > Macro Reference > Tutorial

EmEditor Macro Reference: Using Regular Expressions

Scroll Prev Top Next More
EmEditor Home - EmEditor Help - EmEditor Macro Reference - Tutorial

Using Regular Expressions

To use regular expressions, use the RegExp Object.

The following example code uses regular expressions to determine whether or not the specified string is an email address.


str = "";

re = new RegExp( "^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$", "i" );

result = re.test( str );

if( result ) {

   alert( "The email address is OK." );


else {

   alert( "The email address is invalid." );



str = ""

Set regEx = New RegExp

regEx.Pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"

regEx.IgnoreCase = True

result = regEx.Test( str )

If result Then

   alert "The email address is OK."


   alert "The email address is invalid."

End If


g Microsoft MSDN Library: Regular Expression Object (JavaScript)

g Microsoft MSDN Library: RegExp Object (VBScript)

Copyright © 2003-2021 by Emurasoft, Inc.